Commits

Christian Krebs committed 122889d Draft

const to var.

Comments (0)

Files changed (2)

tests/selector-pattern-matching-performance/test-selectors.js

 {
   Array.prototype.forEach.call(document.getElementsByTagName('link'), function(link)
   {
-    if (/stylesheet/i.test(link.getAttribute('rel'))) 
+    if (/stylesheet/i.test(link.getAttribute('rel')))
     {
       link.disabled = !bool;
     }
 })();
 
 var GetUniqueToken = function()
-{ 
+{
   this._base_token = '';
   this._modulo_count = 0;
   this._count = 0;
   this.get_pattern =function()
   {
     return (
-    escapeTextHtml(this._before) + 
+    escapeTextHtml(this._before) +
     "<span class=\"pattern\">&lt;"+ this.type + "&gt;</span>" +
     escapeTextHtml(this._after));
   };
 
 AttrSelectorGeneratorPrototype = function()
 {
- 
+
   this._init = function(type, match)
   {
     SelectorGenerator.prototype._init.call(this, type, match);
     if (this._attr_val)
     {
       return (
-      escapeTextHtml(this._before + this._arr_key + this._attr_before_val) + 
-      "<span class=\"pattern\">&lt;attr-val&gt;</span>" + 
+      escapeTextHtml(this._before + this._arr_key + this._attr_before_val) +
+      "<span class=\"pattern\">&lt;attr-val&gt;</span>" +
       escapeTextHtml(this._attr_after_val + this._after));
     }
     return (
-    escapeTextHtml(this._before) + 
+    escapeTextHtml(this._before) +
     "<span class=\"pattern\">&lt;attr-key&gt;</span>" +
     escapeTextHtml(this._after));
   };
     {
       return (
       this._before + this._arr_key +
-      this._attr_before_val + this._unique_tokens.next() + this._attr_after_val + 
+      this._attr_before_val + this._unique_tokens.next() + this._attr_after_val +
       this._after);
     }
     return this._before + this._unique_tokens.next() + this._after;
 
 FunctionSelectorGeneratorPrototype = function()
 {
- 
+
  this._init = function(type, match)
  {
    SelectorGenerator.prototype._init.call(this, type, match);
   var re_attr_val = re_str_d_q; // attribute values are normailzed in Opera
   var combinators = "\\)?[\\s>+~]*";
   var ident = "(?:[^() \\[:\\.\\\\]|\\\\\\.)+";
-  var types = 
+  var types =
   [
     {
       name: 'class',
     {
       name: 'attr',
       re: new RegExp("^(" + combinators + "\\[s*)([^=\\] :]+)" +
-                     "(?:(s*=s*\")((?:[^\"\\\\]|\\\\\\.)*)(\"s*))?" + 
+                     "(?:(s*=s*\")((?:[^\"\\\\]|\\\\\\.)*)(\"s*))?" +
                      "(\\])"),
       generator: AttrSelectorGenerator
     },
                      "(?:\\d*n?)(?::+[^\\)]*)?"),
       generator: FunctionSelectorGenerator
 
-    }, 
+    },
   ];
   var match = null;
   var ret = [];
       ret.push(str);
       str = '';
     }
-  } 
+  }
   return {selector: selector, parts: ret};
 }
 
     {
       return typeof part == 'string' ? part : part.get_pattern();
     }).join('') + '</span>';
-    
+
     for (var i = 0; i < 5; i++)
     {
       out += '\n  ' + selector.parts.map(function(part)
   document.getElementsByTagName('pre')[0].innerHTML = out;
 };
 
-const DIV_COUNT = 500;
-const SPAN_COUNT = 6;
+var DIV_COUNT = 500;
+var SPAN_COUNT = 6;
 
 var test_tmpl = function()
 {
 };
 
 var tests = [];
-tests.push( 
+tests.push(
 {
   description: 'no additional style',
   setup: function()
     selector.parts.map(function(part)
     {
       return (typeof part == 'string' ? part : part.iter());
-    }).join('') + 
+    }).join('') +
     " {padding: 1px;}\n");
   }
 
 
 };
 
-const H1 = "<h1>Measuring performance of css selector matching</h1>";
-const DESC = 
+var H1 = "<h1>Measuring performance of css selector matching</h1>";
+var DESC =
 [
   "<p>This test analyses the patterns of a given set of CSS selectors.",
   "The patterns are used to create for each test the given numbers ",
       Array.prototype.forEach.call(sheet.cssRules, function(rule)
       {
         selectors.push.apply(selectors, rule.selectorText.split(/,\s*/));
-      }); 
+      });
     }
     // i && (i=1000)
   }
   return selectors;
 }
 
-var test_config = 
+var test_config =
 {
   before_test_run: function()
   {
     enable_stylesheets(true);
 
-    var selectors = get_selectors(); 
-    
+    var selectors = get_selectors();
+
     enable_stylesheets(false);
-    
+
     var patterns = {};
-    
+
     while (selectors.length)
     {
       var selector = analyze_selector(selectors.pop(), test_config.is_single_varaible);
     this.current_test = tests.pop();
     if (this.current_test)
     {
-      document.getElementById('info').textContent = 
-        "Running test number " + (this.current_test.index + 1) + 
+      document.getElementById('info').textContent =
+        "Running test number " + (this.current_test.index + 1) +
         " of " + this.tests_count +  " tests ...";
       this.current_test.setup();
       return {test: single_test_run, description: this.current_test.description};
     markup += "<table><tr><th>average per test run<th colspan='3'>in % of the best<th>description</tr>" +
               results.map(function(entry)
               {
-                var hue = (entry.average / min)  < 1.5 ? 
-                          (120 - 240 * (entry.average / min - 1)) >> 0 : 
+                var hue = (entry.average / min)  < 1.5 ?
+                          (120 - 240 * (entry.average / min - 1)) >> 0 :
                           0;
                 return (
                 "<tr>" +
-                  "<td>" + entry.average.toFixed(1) + 
+                  "<td>" + entry.average.toFixed(1) +
                   "<td>" + (entry.average / min * 100 >> 0) + "%" +
                   "<td>±" + entry.deviation + '%' +
-                  "<td style='background-color: hsl(" + hue + ", 100%, 50%);'>" + 
+                  "<td style='background-color: hsl(" + hue + ", 100%, 50%);'>" +
                   "<td>" + entry.description +
                 "</tr>");
               }).join('\n') + "</table>";
     document.getElementById('out').innerHTML = markup;
-    document.getElementById('info').innerHTML = '';    
+    document.getElementById('info').innerHTML = '';
   }
 };
 

tests/selector-pattern-matching-performance/testrunner.js

   };
 };
 
-const DELAY_NEXT_RUN = 15;
-const DELAY_NEW_TEST = 90;
+var DELAY_NEXT_RUN = 15;
+var DELAY_NEW_TEST = 90;
 
 var TestRunner = function(config)
 {
   this._before_test_run = config.before_test_run;
   this._prepare_test_run = config.prepare_test_run;
-  /* 
+  /*
     must return an object with test, description
   */
   this._get_next_test = config.get_next_test;
 
   this._run_next_test = function()
   {
-    if (this._current_test) 
+    if (this._current_test)
     {
       if (this._current_test_count < this._test_runs)
       {
         this._current_times = [];
         setTimeout(this._prepare_next_test, DELAY_NEW_TEST);
       }
-      
+
     }
     else
     {
 
   this._start();
 
-}
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.