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: <div id="somelem" class="ui-state-active container"> <ul class="list"> <li><a href="#"><span class="enabled">Test</span></a></li> </ul> </div> Using a hash I can see for some situations, but unless you can figure out a way (and I'd be super interested if you could) to do complex cascade parsing without regex, your method seems like double the work of rewriting with no benefits towards maintainability and a minor speed increase for only certain tags. Just my $.02 On Feb 3, 9:32 am, George Adamson <george.adam...@softwareunity.com> wrote: > (This is really directed at the jQuery core team) > > I notice that jQuery uses regexp statements like this one... (used in > the position() and offsetParent() methods for example) > > .../^body|html$/i.test(offsetParent.tagName) > > Might it be faster to use a simple object hash like this instead...? > > var test = {BODY:true, HTML:true}; > ...test[offsetParent.tagName]; > > I did some crude experiments and found that the hash technique was at > least 4 times faster in IE7 and 15 times faster in FF3. > > I've dumped some more info onhttp://blog.softwareunity.com/ > > I'm interested to hear people's opinions on this as a performance > booster. > (What shall I call it? Sizzle perhaps? No maybe that one's taken...)