Skip to content

cleanup(localized_reader): drop unused seen HashSet (#190)#242

Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:cleanup/localized-reader-drop-unused-seen-190
Closed

cleanup(localized_reader): drop unused seen HashSet (#190)#242
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5:cleanup/localized-reader-drop-unused-seen-190

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 29, 2026

Closes #190.

read_flat_files allocated a HashSet<String> and threaded it as &mut seen through scan_directory recursion just to call seen.insert(full_name.clone()) once per new entry. The set was never read for dedup — entries.iter_mut().find(|e| e.name == full_name) is the actual existence check on the line above. (#191 tracks the O(n²) → HashMap follow-up; this PR is just the dead write.)

Removing the parameter:

  • Deletes a per-call String::clone (set insertion took ownership of a clone of the name we already used to construct the entry).
  • Drops the HashSet allocation on every call to read_flat_files.
  • Removes the use std::collections::HashSet import.
  • Simplifies scan_directory's signature (4 args → 3).

Test plan

  • cargo build --manifest-path sdk/Cargo.toml — clean
  • cargo test --manifest-path sdk/Cargo.toml --lib repositories — 45/45 repository tests pass
  • cargo clippy --manifest-path sdk/Cargo.toml --lib — no new warnings on localized_reader.rs

TrueNine and others added 2 commits April 25, 2026 10:10
Fix two CI failures from previous merge
Closes TrueNine#190.

`read_flat_files` allocated a `HashSet<String>` and threaded it as
`&mut seen` through `scan_directory` recursion just to call
`seen.insert(full_name.clone())` once per new entry. The set was
never read for dedup — `entries.iter_mut().find(|e| e.name ==
full_name)` is the actual existence check on the line above (TrueNine#191
tracks the O(n²) → HashMap follow-up; this PR is just the dead
write).

Removing the parameter:

  - Deletes a per-call `String::clone` (set insertion took ownership
    of a clone of the name we already used to construct the entry).
  - Drops the `HashSet` allocation on every call to `read_flat_files`.
  - Removes the `use std::collections::HashSet` import.
  - Simplifies `scan_directory`'s signature (4 args → 3).

`cargo build` + `cargo test --lib repositories` clean (45/45
repository tests pass). `cargo clippy --lib` shows no new warnings
on `localized_reader.rs`.
@SAY-5 SAY-5 requested a review from TrueNine as a code owner April 29, 2026 21:54
@TrueNine TrueNine changed the base branch from main to dev April 30, 2026 08:08
@TrueNine
Copy link
Copy Markdown
Owner

Merged into dev via cherry-pick. The PR base was changed from main to dev, which caused conflicts because dev had diverged significantly. All commits have been cherry-picked onto dev and pushed. Thanks for the contributions!

@TrueNine TrueNine closed this Apr 30, 2026
@TrueNine
Copy link
Copy Markdown
Owner

Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Localized Reader] seen HashSet 写入但从未读取

2 participants