[Jifty-commit] r4648 - in jifty/trunk: share/web/static/js/cssquery

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Dec 7 19:05:51 EST 2007


Author: sartak
Date: Fri Dec  7 19:05:51 2007
New Revision: 4648

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/share/web/static/js/cssquery/cssQuery.js

Log:
 r48775 at onn:  sartak | 2007-12-07 19:05:34 -0500
 Shave off another 100ms by special casing the beastly 40% function


Modified: jifty/trunk/share/web/static/js/cssquery/cssQuery.js
==============================================================================
--- jifty/trunk/share/web/static/js/cssquery/cssQuery.js	(original)
+++ jifty/trunk/share/web/static/js/cssquery/cssQuery.js	Fri Dec  7 19:05:51 2007
@@ -106,8 +106,26 @@
 // selectors
 // -----------------------------------------------------------------------
 
+// Jifty: special case of the descent selector. this is by far the most time
+// consuming code path of JS. special casing it does cut JS time a bit
+selectAll = function($results, $from) {
+	// loop through current selection
+	var $element, $subset, i, j;
+	for (i = 0; i < $from.length; i++) {
+        $subset = $from[i].getElementsByTagName("*");
+		for (j = 0; ($element = $subset[j]); j++) {
+			if (thisElement($element))
+		        $results.push($element);
+		}
+	}
+};
+
 // descendant selector
 selectors[" "] = function($results, $from, $tagName, $namespace) {
+    if ($tagName == "*" && $namespace == "") {
+        return selectAll($results, $from);
+    }
+
 	// loop through current selection
 	var $element, i, j;
 	for (i = 0; i < $from.length; i++) {


More information about the Jifty-commit mailing list