Repository navigation
perf(sidebar): match ASCII names by bytes and filter each container once per query - #4596
Merged
Merged
Conversation
…nce per query The sidebar filter searched every name with localizedStandardRange. An ASCII name against an ASCII query now takes a byte search, and the locale-aware search keeps every other name and any locale that folds ASCII letters differently. The bodies around the outline read one memo of container verdicts, and the view model's bindings stop publishing when SidebarView hands them over.
datlechin
enabled auto-merge (squash)
November 26, 2026 01:51
…'s test arguments need
…leared search keeps no catalog buffers
…n the current locale
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.
Summary
SidebarNameQueryfolds the query once. An ASCII name against an ASCII query takes a byte search; any other name, any other query, and any locale that folds the 26 ASCII letters differently from bytes (Turkish foldsIto a dotlessı) keepslocalizedStandardRange, so every answer stays what it was.SidebarViewModelkeeps aDatabaseTreeBucketMemoper container, andSidebarTreeView.visibleSchemasandSidebarView'sotherSchemaMatchesandattachedSchemaMatchespass it asfilter:tohierarchicalLoadedContentandloadedObjectBuckets. An unrelated publish during a search no longer filters every loaded container again, andSidebarTreeViewcomputesschemasonce per body.SidebarView.inithands over on every evaluation of its parent are plain properties, so the handover publishes nothing.Measured with a
swiftc -Oprobe of both searches, one pass over 100,000 ASCII names on this Mac:localizedStandardRangetorordorder_itemA sweep of 300,000 random printable-ASCII name and query pairs gave the same tier from both paths under
en; undertr_TRit gave 83 differences, which is why the locale check exists.Left for a follow-up, on #4532: the scan in a
@concurrentpass with cancellation and narrowing from the previous matches, and the outline nodes built once per catalog load (SQ6 of #4438). The filter's callers read its verdicts synchronously, from the outline's node build and from the bodies, so moving the scan off the main actor makes that an async pipeline; that is its own change.Test plan
SidebarNameFilterTests: non-ASCII cases (ß, thefiligature,İandı, combining and precomposedé,æ,Ø) answer what the locale-aware search answers in the current locale, so the case holds under Turkish too; every ASCII query against every ASCII name, punctuation included, matches the locale-aware search; a Turkish locale takes the locale-aware path.SidebarViewModelTests: handing over new bindings publishes nothing; a container's remembered verdict follows its query; clearing the search lets go of the rows the container memo held (the memo is emptied on every query change, not only at the next lookup, which never comes once the field is empty).verify.sh test SidebarNameFilterTests SidebarSearchTests SidebarViewModelTests DatabaseTreeFilterTestson the head merged with main: 70 passed.SidebarNameMatchTieris declaredSendable: a public enum is not inferred so, and the test arguments need it (CI's compile error).Closes #4532