Optimized replace method to skip unused code.
authorJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 27 Nov 2011 09:02:51 +0000 (10:02 +0100)
committerJakub Pawlowicz <jakub@goalsmashers.com>
Sun, 27 Nov 2011 09:02:51 +0000 (10:02 +0100)
lib/clean.js

index f065468..425b343 100644 (file)
@@ -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');
       }
     };