On 9/24/09 6:29 AM, Sean Hogan wrote:
I would be surprised if an implementation didn't create an internal
lookup table keyed off the selector text.
Gecko doesn't. Webkit doesn't.
I just checked really quickly, and on my machine (a year-plus old
laptop) parsing the ".foo .bar .baz" selector and destroying the
selector object before returning in Gecko takes about 80% of the
"overhead" (that is, not walking the tree and doing selector matching)
time of a querySelector() call. Or, in numbers, about 5.5us per call.
Webkit's time for executing my testcase is comparable, though I can't
tell how much of their time is selector parsing.
If you're doing less than 1,000 calls that involve selectors api per
second, the selector-parsing time is probably not that relevant. But I
don't know what the use cases are here.
-Boris