I think this should be posted at jquery-dev. There is no significant
difference between the hash and switch options, less than 10ms for
200.000 iterations (FF3). But both offer a solid speed improvement
over a simple regex in the case posted when dealing with hundreds of
calls. That could be impor
On Feb 3, 2009, at 12:39 PM, George Adamson wrote:
Absolutely, it is very very limited. So this technique is only suited
to the type of regex's that I quoted, like the one used internally by
jquery to test for body or html tags only, or to test for t(able|d|h)
only. Particulalry when used insi
I imagine a switch is the same speed as a hash (switches generally
evaluate to a hash). Using a trie structure could be faster than
regex in some circumstances I imagine:
http://en.wikipedia.org/wiki/Trie
On Feb 3, 12:45 pm, Eric Garside wrote:
> In that case, wouldn't a switch statement have
In that case, wouldn't a switch statement have even less overhead than
creating an object to check everytime? I'd think
switch(tag){case 'body':case 'html': /* ... */ break;} would be an
even faster solution, no?
On Feb 3, 12:39 pm, George Adamson
wrote:
> Absolutely, it is very very limited. S
Absolutely, it is very very limited. So this technique is only suited
to the type of regex's that I quoted, like the one used internally by
jquery to test for body or html tags only, or to test for t(able|d|h)
only. Particulalry when used inside a loop. For parsing a selector we
still need regex.
The problem I can forsee getting into is the sheer lack of power in a
hash. It's stock and faster for a reason: everything is predefined and
a simple check. Try your method vs. jQuery's on the following
selector:
"#somelem.ui-state-active.container .list li a span.enabled"
That should match only
6 matches
Mail list logo