Ticket #5076 (closed enhancement: invalid)
Improving jQuery.filter performances for simple selectors would benefit .is(), .hasClass(), .closest() and .live()
|Reported by:||lrbabe||Owned by:||lrbabe|
Currently .is() and .hasClass() underlying algorithm has an O(n) complexity while .closest() and .live() complexity is O(n²). However, for simple selectors of the form "div", ".class" or "div.class" the complexity could respectively be O and O(n) by directly checking the nodes without querying the DOM.
The attached patch adds a dozen lines of code to jQuery.filter() to enable this behavior and has a very limited impact on performance for other selectors.
See related post on google groups for additional details and performance numbers: http://groups.google.com/group/jquery-dev/browse_thread/thread/99dc2e890e423bd7