Closed Bug 932870 Opened 11 years ago Closed 11 years ago

Used the parsed-selector cache even for invalid selectors

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

We want this because jQuery commonly passes those in (when consumers are using its selector extensions), and we'd like to avoid reparsing them.  What we can do is just cache a null selector and use null to indicate "invalid, throw".

On the testcase in bug 922048 this drops my times from about 1850ms to about 1650ms.
Comment on attachment 824732 [details] [diff] [review]
Cache the "invalid selector" state in our parsed-selector cache as well when doing querySelector(All).


>+    } else if (!selectorList) {
>+      // This is the "only pseudo-element selectors" case, which is
>+      // not common, so just don't worry about caching it.  That way a
>+      // null cached value can always indicate an invalid selector.
>+      // Also don't try to do any matching, of course.
>+      return NS_OK;
Odd, but apparently http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsINode.cpp#2311 does that.
Attachment #824732 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/90ca96b3e198
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: