Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
## 2026-05-04 - [Fix CI SIGTRAP Failure]

**Learning:** `xvfb-run` crashes with `SIGTRAP` in GitHub Actions for `vscode-extension` integration tests if they run too soon after `dbus` services start or fail, likely due to missing display configurations in the headless agent environment for Electron integration testing via `@vscode/test-electron`. Wait! No, that's from my past memory. Let me see what I just fixed. I fixed `indexer-worker.ts` with `pLimit`. Let's just submit.
## 2024-05-18 - Lazy Evaluation of Pre-computed Full Names in Search Engine
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix the journal date.

2024-05-18 is out of sequence with the surrounding 2026 entries and this PR’s May 6, 2026 timeline, so the optimization will look like it landed two years earlier than it actually did.

Suggested fix
-## 2024-05-18 - Lazy Evaluation of Pre-computed Full Names in Search Engine
+## 2026-05-06 - Lazy Evaluation of Pre-computed Full Names in Search Engine
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## 2024-05-18 - Lazy Evaluation of Pre-computed Full Names in Search Engine
## 2026-05-06 - Lazy Evaluation of Pre-computed Full Names in Search Engine
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.jules/bolt.md at line 35, The journal header "## 2024-05-18 - Lazy
Evaluation of Pre-computed Full Names in Search Engine" has the wrong year;
update the date to the correct 2026 year to match surrounding entries and this
PR timeline (e.g., change "2024-05-18" to "2026-05-18") so the entry appears in
sequence.

**Learning:** In the `SearchEngine.burstSearch` hot loop, calling `fullName.toLowerCase()` for every item when no fast-path exact or prefix match is found creates a significant amount of redundant string allocations, leading to performance bottlenecks during exhaustive scans.
**Action:** Implemented lazy evaluation of `_targetLower` from the parallel `this.preparedFullNames` array in `calculateMatchScore`. By passing the pre-computed Fuzzysort prepared object down, we only extract its lowercased string if the fast paths fail, avoiding unnecessary O(N) evaluations and memory allocations.
12 changes: 8 additions & 4 deletions language-server/src/core/search-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,7 @@ export class SearchEngine implements ISearchProvider {
? (prepared as unknown as ExtendedPrepared)._targetLower
: item.name.toLowerCase();

const score = this.calculateMatchScore(nameLower, item.fullName, queryLower);
const score = this.calculateMatchScore(nameLower, item.fullName, this.preparedFullNames[i], queryLower);
if (score > 0) {
addResult(item, this.itemTypeIds[i], score);
}
Expand All @@ -2248,7 +2248,7 @@ export class SearchEngine implements ISearchProvider {
return results;
}

private calculateMatchScore(nameLower: string, fullName: string | undefined, queryLower: string): number {
private calculateMatchScore(nameLower: string, fullName: string | undefined, preparedFullName: Fuzzysort.Prepared | null, queryLower: string): number {
// Fast path: Exact match or prefix match
if (nameLower === queryLower || nameLower.indexOf(queryLower) === 0) {
return 1.0;
Expand All @@ -2259,9 +2259,13 @@ export class SearchEngine implements ISearchProvider {
return 0.8;
}

// Check fullName if it exists and is different from name
// Check fullName if it exists
if (fullName) {
const fullLower = fullName.toLowerCase();
// ⚡ Bolt: Lazy retrieval of pre-computed lowercased fullName to avoid redundant string allocations
const fullLower = preparedFullName
? (preparedFullName as unknown as ExtendedPrepared)._targetLower
: fullName.toLowerCase();

if (fullLower !== nameLower) {
if (fullLower === queryLower || fullLower.indexOf(queryLower) === 0) {
return 0.9;
Expand Down
Loading