Repository navigation
[Repo Assist] perf: avoid heap allocations in local-filter search for ASCII names/IDs - #511
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
App::apply_filter() calls to_lowercase() on every package name and id on every keystroke in the local filter/search box. This allocates two new Strings per package per call, even though package names/ids are almost always pure ASCII. Add a contains_ignore_case() helper that takes a zero-allocation ASCII-only fast path (byte-slice windows() scan with eq_ignore_ascii_case) when both haystack and query are ASCII, falling back to the existing to_lowercase().contains() behavior for non-ASCII input. The query is lowercased once per apply_filter() call instead of once per package. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This is an automated contribution from Repo Assist, an AI assistant for this repository.
What
App::apply_filter()'s local-package-filter path (used for the Installed/Upgrades local filter and the Search-view narrowing) calledto_lowercase()on every package'snameandidinside theretain()closure, on every single call — which fires on every keystroke while typing a filter. Each call allocates two new heapStrings per package, even though package names and IDs are almost always pure ASCII.Fix
Added a
contains_ignore_case(haystack, query, query_lower)helper insrc/app.rs:windows()scan witheq_ignore_ascii_case) when both the haystack and query are ASCII — the overwhelmingly common case for winget package metadata.to_lowercase().contains()behavior for non-ASCII input, so Unicode package names/ids still match correctly.apply_filter()call (outside the loop) instead of allocating fresh strings per package.This mirrors the existing ASCII-fast-path convention already used in
cli_backend.rs::normalize_show_key().Trade-offs
None expected — this is a pure performance optimization with identical observable behavior (same case-insensitive substring matching semantics), verified by new and existing tests.
Test Status
cargo check --all-targets— ✅ passcargo fmt -- --check— ✅ passcargo clippy --all-targets -- -D warnings— ✅ pass, no warningscargo test— ✅ 450 passed, 0 failed (up from 445; added 5 new unit tests forcontains_ignore_casecovering ASCII match/no-match, empty query, query-longer-than-haystack, and non-ASCII fallback)Closes no specific issue — this was identified during a routine performance-improvement pass (Task 8) of the Repo Assist workflow.
Add this agentic workflow to your repo
To install this agentic workflow, run