minor code review

This commit is contained in:
gorhill 2016-07-01 14:33:43 -04:00
parent 9d8499b4b1
commit 973d3e79c1
2 changed files with 21 additions and 25 deletions

View file

@ -63,12 +63,12 @@ if ( vAPI.sessionId ) {
} }
/******************************************************************************/ /******************************************************************************/
/*
vAPI.executionCost = { vAPI.executionCost = {
start: function(){}, start: function(){},
stop: function(){} stop: function(){}
}; };
/* */
vAPI.executionCost = { vAPI.executionCost = {
tcost: 0, tcost: 0,
tstart: 0, tstart: 0,
@ -106,7 +106,7 @@ vAPI.executionCost = {
); );
} }
}; };
*/
vAPI.executionCost.start(); vAPI.executionCost.start();
/******************************************************************************/ /******************************************************************************/

View file

@ -98,11 +98,11 @@ vAPI.domFilterer = {
addSelector: function(s) { addSelector: function(s) {
if ( this.allSelectors[s] || this.allExceptions[s] ) { if ( this.allSelectors[s] || this.allExceptions[s] ) {
return; return this;
} }
this.allSelectors[s] = true; this.allSelectors[s] = true;
if ( s.charCodeAt(s.length-1) === 0x29 && this.addSelectorEx(s) ) { if ( s.charCodeAt(s.length-1) === 0x29 && this.addSelectorEx(s) ) {
return; return this;
} }
if ( s.indexOf(' ') === -1 ) { if ( s.indexOf(' ') === -1 ) {
this.simpleSelectors.push(s); this.simpleSelectors.push(s);
@ -113,6 +113,7 @@ vAPI.domFilterer = {
this.complexSelectorsCost = 0; this.complexSelectorsCost = 0;
} }
this.newDeclarativeSelectors.push(s); this.newDeclarativeSelectors.push(s);
return this;
}, },
addSelectorEx: function(s) { addSelectorEx: function(s) {
@ -992,15 +993,13 @@ vAPI.executionCost.start();
// form, as the generic will affect all related specific forms // form, as the generic will affect all related specific forms
selector = '[' + attr + '="' + attrValue + '"]'; selector = '[' + attr + '="' + attrValue + '"]';
if ( generics.hasOwnProperty(selector) ) { if ( generics.hasOwnProperty(selector) ) {
domFilterer.addSelector(selector); domFilterer.addSelector(selector).hideNode(node);
domFilterer.hideNode(node);
continue; continue;
} }
// Candidate 2 = specific form // Candidate 2 = specific form
selector = node.localName + selector; selector = node.localName + selector;
if ( generics.hasOwnProperty(selector) ) { if ( generics.hasOwnProperty(selector) ) {
domFilterer.addSelector(selector); domFilterer.addSelector(selector).hideNode(node);
domFilterer.hideNode(node);
} }
} }
} }
@ -1033,29 +1032,26 @@ vAPI.executionCost.start();
var processHighMediumGenericsForNodes = function(nodes, generics) { var processHighMediumGenericsForNodes = function(nodes, generics) {
var i = nodes.length, var i = nodes.length,
node, href, pos, hash, selectors, j, selector, node, href, pos, entry, j, selector;
aa = [ '' ];
while ( i-- ) { while ( i-- ) {
node = nodes[i]; node = nodes[i];
href = node.getAttribute('href'); href = node.getAttribute('href');
if ( !href ) { continue; } if ( !href ) { continue; }
pos = href.indexOf('://'); pos = href.indexOf('://');
if ( pos === -1 ) { continue; } if ( pos === -1 ) { continue; }
hash = href.slice(pos + 3, pos + 11); entry = generics[href.slice(pos + 3, pos + 11)];
selectors = generics[hash]; if ( entry === undefined ) { continue; }
if ( selectors === undefined ) { continue; } if ( typeof entry === 'string' ) {
// A string. if ( href.lastIndexOf(entry.slice(8, -2), 0) === 0 ) {
if ( typeof selectors === 'string' ) { domFilterer.addSelector(entry).hideNode(node);
aa[0] = selectors; }
selectors = aa; continue;
} }
// An array of strings. j = entry.length;
j = selectors.length;
while ( j-- ) { while ( j-- ) {
selector = selectors[j]; selector = entry[j];
if ( href.lastIndexOf(selector.slice(8, -2), 0) === 0 ) { if ( href.lastIndexOf(selector.slice(8, -2), 0) === 0 ) {
domFilterer.addSelector(selector); domFilterer.addSelector(selector).hideNode(node);
domFilterer.hideNode(node);
} }
} }
} }
@ -1197,9 +1193,9 @@ vAPI.executionCost.start();
// Added node lists will be cumulated here before being processed // Added node lists will be cumulated here before being processed
var addedNodeLists = []; var addedNodeLists = [];
var addedNodeListsTimer = null; var addedNodeListsTimer = null;
var addedNodeListsTimerDelay = 25; var addedNodeListsTimerDelay = 0;
var removedNodeListsTimer = null; var removedNodeListsTimer = null;
var removedNodeListsTimerDelay = 25; var removedNodeListsTimerDelay = 5;
var collapser = domCollapser; var collapser = domCollapser;
var addedNodesHandler = function() { var addedNodesHandler = function() {