New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$.find: added indexOf checking for jqmData selector to improve speed on non-jqm selectors #5999

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@tosyu

tosyu commented May 13, 2013

$.find always runs regexp on given selector string. The problem is, that some apps (and even some widgets) do more normal selector searching than :jqmData searching.

I added checking for :jqmData keyword in selector by simple indexOf method, which is faster, not that it makes a huge difference, but still.

Please refer to the test on http://jsperf.com/jquery-mobile-find-patch-performance-fix

Note that the

jqmSelector = ":jqmData",
jqmDataRE = /:jqmData\(([^)]*)\)/g;

duplication could be changed also

Krzysztof Antoszek
$.find: added indexOf checking form jqmData selector to improve
speed on non-jqm selectors

jQuery Mobile added ":jqmData" selector by decorating the standard
$.find method with a regexp for every selector supplied in the
method. But not every selector is a ":jqmData" selector so that
hit performance. I've added a simple indexOf check is faster
then always replacing contents in a selector; when the ":jqmData"
selector is found, then te regexp replace will occur.

Please refer to test on jsperf:
    http://jsperf.com/jquery-mobile-find-patch-performance-fix

@arschmitz arschmitz closed this in 375b21b Aug 6, 2013

@arschmitz

This comment has been minimized.

Show comment
Hide comment
@arschmitz

arschmitz Aug 6, 2013

Member

@tosyu thank you for the PR there were some merge conflicts though so i manually applied this commit

Member

arschmitz commented Aug 6, 2013

@tosyu thank you for the PR there were some merge conflicts though so i manually applied this commit

@tosyu

This comment has been minimized.

Show comment
Hide comment
@tosyu

tosyu Aug 20, 2013

Ok, thanks!

tosyu commented Aug 20, 2013

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment