element-web-0001: TextForEvent.tsx user dedup array → Set (15x, HIGH) element-web-0002: TextForEvent.tsx pinned filter indexOf → Set.has (13x, MEDIUM) bun-0001: yarn.zig scoped version two-pass scan → single pass (4x, MEDIUM) 5 tests: 5/5 PASS
41 lines
1.8 KiB
Diff
41 lines
1.8 KiB
Diff
--- a/src/install/yarn.zig
|
|
+++ b/src/install/yarn.zig
|
|
@@ -773,20 +773,18 @@ fn populatePackageVersionMap(
|
|
var found_existing = false;
|
|
var found_new = false;
|
|
+ var found_package_id: Install.PackageID = 0;
|
|
for (list.items) |item| {
|
|
if (strings.eql(item.version, existing.version)) found_existing = true;
|
|
- if (strings.eql(item.version, version)) found_new = true;
|
|
+ if (strings.eql(item.version, version)) {
|
|
+ found_new = true;
|
|
+ found_package_id = item.package_id; // capture in first pass
|
|
+ }
|
|
}
|
|
|
|
if (!found_existing) {
|
|
try list.append(.{
|
|
.yarn_idx = existing.yarn_idx,
|
|
.version = existing.version,
|
|
.package_id = existing.package_id,
|
|
});
|
|
}
|
|
|
|
if (!found_new) {
|
|
const package_id = next_package_id;
|
|
next_package_id += 1;
|
|
try list.append(.{
|
|
.yarn_idx = yarn_idx,
|
|
.version = version,
|
|
.package_id = package_id,
|
|
});
|
|
yarn_entry_to_package_id[yarn_idx] = package_id;
|
|
} else {
|
|
- for (list.items) |item| { // O(M) second scan — eliminated
|
|
- if (strings.eql(item.version, version)) {
|
|
- yarn_entry_to_package_id[yarn_idx] = item.package_id;
|
|
- break;
|
|
- }
|
|
- }
|
|
+ yarn_entry_to_package_id[yarn_idx] = found_package_id;
|
|
}
|