Perf: Compare regexes as strings when checking imagery blocklists #8860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.