Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

optimization: only sort top N items when numResultsShown option is passed #9

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nojvek
Copy link
Contributor

@nojvek nojvek commented Mar 21, 2021

Sorting a large array is quite expensive, >500ms for ~50,000 strings. Usually the UI only displays ~100 or so items. The optimization switches to bubble sort and only sorts top N items if N is much smaller than total number of results.

This ensures that pressing the first key stroke e.g 'a' can have its results computed in <50ms. Previously this needed a debounce due to large sorting overhead. Now we react on every keystroke and UI feels very responsive.

@nojvek nojvek changed the base branch from nojvek-camelCase-search to master April 25, 2021 01:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants