Skip to content

Optimize proxy search filter to reduce redundant string operations#348

Open
lamtrinhdev wants to merge 1 commit into
mullvad:mainfrom
lamtrinhdev:main
Open

Optimize proxy search filter to reduce redundant string operations#348
lamtrinhdev wants to merge 1 commit into
mullvad:mainfrom
lamtrinhdev:main

Conversation

@lamtrinhdev
Copy link
Copy Markdown

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.

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.
@ruihildt
Copy link
Copy Markdown
Member

ruihildt commented May 7, 2026

Thanks for submitting this improvement.

@hankolsen Would you mind reviewing it?

Copy link
Copy Markdown
Collaborator

@hankolsen hankolsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lamtrinhdev
Copy link
Copy Markdown
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,
Lam

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants