From 0468e31bf703815f2d145877280b71e9eadaf6f0 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 20 Jan 2009 19:47:15 +0000 Subject: [PATCH] Added a performance improvement to preFilter.CLASS from LosT on the Sizzle.js mailing list. --- src/selector.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/selector.js b/src/selector.js index 56efd01..d7d56c2 100644 --- a/src/selector.js +++ b/src/selector.js @@ -332,11 +332,12 @@ var Expr = Sizzle.selectors = { CLASS: function(match, curLoop, inplace, result, not){ match = " " + match[1].replace(/\\/g, "") + " "; - for ( var i = 0; curLoop[i] != null; i++ ) { - if ( curLoop[i] ) { - if ( not ^ (" " + curLoop[i].className + " ").indexOf(match) >= 0 ) { + var elem; + for ( var i = 0; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (" " + elem.className + " ").indexOf(match) >= 0 ) { if ( !inplace ) - result.push( curLoop[i] ); + result.push( elem ); } else if ( inplace ) { curLoop[i] = false; } -- 1.7.10.4