Skip to content
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

Perf: Compare regexes as strings when checking imagery blocklists #8860

Merged
merged 1 commit into from
Dec 29, 2021

Conversation

bhousel
Copy link
Member

@bhousel bhousel commented Dec 22, 2021

We were profiling some other things and realized that iD is spending some non-trivial time retesting all the imagery sources against the the blocklist regexes on every render. This was happening because regexes are Objects in Javascript and so will always look different unless they are compared as strings.

Screen Shot 2021-12-22 at 10 42 10 AM

This PR restructures the code a bit so that the blocklist regexes are compared as strings, and the regexes get retested against all the sources only if something really changed.

…rame

Regexes are objects so comparing them with === will always return false
This was causing the sources to be rechecked every frame.
@tyrasd tyrasd merged commit d1410bc into develop Dec 29, 2021
@tyrasd tyrasd temporarily deployed to workflows December 29, 2021 08:46 Inactive
@tyrasd tyrasd deleted the blocklist-perf branch December 29, 2021 08:46
@tyrasd tyrasd added the performance Optimizing for speed and efficiency label Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Optimizing for speed and efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants