Skip to content

Share one type_bucket function among the per-type containers - #67

Merged
droundy merged 1 commit into
masterfrom
simplify
Oct 18, 2026
Merged

droundy merged 1 commit into
masterfrom
simplify

Conversation

@droundy

@droundy droundy commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

container.rs (used by Intern), append_container.rs (Intern32) and typearena.rs (NewIntern) each contained an identical ~35-line hash_of_type function with its own HasherForTypeId, plus their own 32 constant for the number of buckets. This moves both into a new src/type_bucket.rs:

  • TYPE_BUCKETS: the number of buckets (32), now defined once;
  • type_bucket::<T>(): which bucket holds T's container (the old hash, taken modulo TYPE_BUCKETS).

The callers shrink to self.containers[type_bucket::<T>()]. Net: −132/+23 lines in the existing files, plus the new 50-line module (including a small test).

Behaviour

Unchanged. The hasher and the arithmetic are the same, and each caller hashes the same type as before. In particular typearena.rs hashed Mutex<HashSet<T>> rather than T, and still does (type_bucket::<Mutex<HashSet<T>>>()), so every type lands in the same bucket.

Test plan

  • cargo test --all-features -- --test-threads=1 and cargo test
  • cargo check with default features, --features _experimental-new-intern, --features arc,tinyset, --no-default-features --features arc, --all-features; no new warnings or errors (the existing ones, e.g. --features intern32 without deepsize, are fixed separately in Move the benchmarks to scaling 0.9, and compare with the previous release #66)
  • cargo +1.71.0 check --all-features

Independent of #66; based on master.

🤖 Generated with Claude Code

container.rs, append_container.rs and typearena.rs each defined the same
hash_of_type function, with its own HasherForTypeId, and their own
32-bucket constant.  Move both into a type_bucket module, so how a type
picks its bucket is written once.  Each caller hashes the same type as
before, so every type stays in the same bucket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.14286% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.51%. Comparing base (49dd84c) to head (3f455a8).

Files with missing lines Patch % Lines
src/type_bucket.rs 76.19% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   80.17%   79.51%   -0.67%     
==========================================
  Files          10       11       +1     
  Lines        2068     1884     -184     
==========================================
- Hits         1658     1498     -160     
+ Misses        410      386      -24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@droundy
droundy merged commit 431d107 into master Oct 18, 2026
9 of 16 checks passed
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.

1 participant