regex optimizing

This commit is contained in:
James Campos 2011-06-08 09:16:31 -07:00
parent 6c7d31fe94
commit 7018135669
2 changed files with 2 additions and 5 deletions

View File

@ -1698,10 +1698,8 @@
}, },
foo: function() { foo: function() {
var code; var code;
code = $.config('time').replace(/%(.)/g, function(s, c) { code = $.config('time').replace(/%([A-Za-z])/g, function(s, c) {
switch (c) { switch (c) {
case '%':
return '%';
case 'a': case 'a':
case 'd': case 'd':
case 'H': case 'H':

View File

@ -1353,9 +1353,8 @@ time =
$.replace s, timeEl $.replace s, timeEl
foo: -> foo: ->
code = $.config('time').replace /%(.)/g, (s, c) -> code = $.config('time').replace /%([A-Za-z])/g, (s, c) ->
switch c switch c
when '%' then '%'
when 'a', 'd', 'H', 'm', 'M', 'p', 'P', 'y' then "' + time.#{c}() + '" when 'a', 'd', 'H', 'm', 'M', 'p', 'P', 'y' then "' + time.#{c}() + '"
else s else s
time.funk = Function 'time', "return '#{code}'" time.funk = Function 'time', "return '#{code}'"