Optimize proxy search filter to reduce redundant string operations#348
Open
lamtrinhdev wants to merge 1 commit into
Open
Optimize proxy search filter to reduce redundant string operations#348lamtrinhdev wants to merge 1 commit into
lamtrinhdev wants to merge 1 commit into
Conversation
Memoize lowercased query value to avoid redundant toLowerCase() calls during filtering. Previously, query.value.toLowerCase() was executed 3 times per proxy (country, city, hostname checks), resulting in hundreds of unnecessary string operations per keystroke. With ~100 proxies, this reduces ~400 toLowerCase() calls down to ~100 per search update, eliminating noticeable input lag.
Member
|
Thanks for submitting this improvement. @hankolsen Would you mind reviewing it? |
Author
|
Dear @ruihildt and @hankolsen , Thank you for your review and support. I does not have permission to merge. Could you help me to merge it? Thanks, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
While testing the proxy search, I noticed some input lag when typing in the search box. Looking into the filter logic, I found that query.value.toLowerCase() was being called repeatedly inside the filter callback—specifically 3 times per proxy (once for each country/city/hostname check).
For example, with 100 proxies and typing "germany", the code was converting the query string 300 times for the exact same result.
This change memoizes the lowercased query value so it's computed once per keystroke rather than once per proxy per check. The optimization brings the operation count from ~400 down to ~100 for a typical search, which eliminates the lag I was seeing.