Skip to content

Conversation

@TrevorBurnham
Copy link
Contributor

Description

This PR optimizes the filterOptions utility used by Select, Multiselect, Autosuggest, and other dropdown components to improve filtering performance.

Changes

  1. Pre-allocate searchableTagFields arrays - Moved the searchableTagFields arrays (['tags'] and ['tags', 'filteringTags']) to module scope instead of creating new arrays on every matchesSingleOption call.

  2. Hoist toLowerCase() outside the loop - The search text normalization is now done once per filter operation instead of once per option.

Performance Impact

Micro-benchmarks show:

  • ~29% overall improvement across test cases
  • Up to 2x speedup for larger option lists (200+ items)

Related Components

This optimization benefits all components that use dropdown filtering:

  • Select
  • Multiselect
  • Autosuggest
  • PropertyFilter

How has this been tested?

Existing tests provide extensive coverage for this functionality.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Move searchableTagFields arrays to module scope to avoid creating
  new arrays on every matchesSingleOption call
- Move toLowerCase() outside the filter loop so it's called once per
  filter operation instead of once per option

Benchmarks show ~29% overall improvement, with up to 2x speedup for
larger option lists (200+ items).
@TrevorBurnham TrevorBurnham requested a review from a team as a code owner January 25, 2026 14:13
@TrevorBurnham TrevorBurnham requested review from taheramr and removed request for a team January 25, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant