From 701813566951df946db35c0ff5ea6b4a08fbadab Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 8 Jun 2011 09:16:31 -0700 Subject: [PATCH] regex optimizing --- 4chan_x.user.js | 4 +--- script.coffee | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 229e8a443..56827f3f5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1698,10 +1698,8 @@ }, foo: function() { var code; - code = $.config('time').replace(/%(.)/g, function(s, c) { + code = $.config('time').replace(/%([A-Za-z])/g, function(s, c) { switch (c) { - case '%': - return '%'; case 'a': case 'd': case 'H': diff --git a/script.coffee b/script.coffee index ec56073f6..484b6901f 100644 --- a/script.coffee +++ b/script.coffee @@ -1353,9 +1353,8 @@ time = $.replace s, timeEl foo: -> - code = $.config('time').replace /%(.)/g, (s, c) -> + code = $.config('time').replace /%([A-Za-z])/g, (s, c) -> switch c - when '%' then '%' when 'a', 'd', 'H', 'm', 'M', 'p', 'P', 'y' then "' + time.#{c}() + '" else s time.funk = Function 'time', "return '#{code}'"