From: Jakub Pawlowicz Date: Sun, 27 Nov 2011 09:02:51 +0000 (+0100) Subject: Optimized replace method to skip unused code. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=5f1379e04452b1d9d6053826bd6c855ce173f890;p=clean-css.git Optimized replace method to skip unused code. --- diff --git a/lib/clean.js b/lib/clean.js index f065468d..425b343f 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -14,15 +14,15 @@ var CleanCSS = { // replace function var replace = function(pattern, replacement) { - var start = new Date().getTime(); - data = data.replace(pattern, replacement); - var end = new Date().getTime(); + if (true) { + data = data.replace(pattern, replacement); + } else { // for debugging purposes only + var start = new Date().getTime(); + data = data.replace(pattern, replacement); + var end = new Date().getTime(); - if (false && end > start) { - sys.print(pattern); - sys.print(' -> '); - sys.print(end - start); - sys.print(' milliseconds\n'); + if (end > start) + sys.print(pattern + ' -> ' + (end - start) + ' milliseconds\n'); } };