Skip to content

fix: HashTable.all() skips entries keyed 0n#115

Closed
ejtriple wants to merge 1 commit into
LostCityRS:274from
ejtriple:fix/hashtable-zero-key
Closed

fix: HashTable.all() skips entries keyed 0n#115
ejtriple wants to merge 1 commit into
LostCityRS:274from
ejtriple:fix/hashtable-zero-key

Conversation

@ejtriple

Copy link
Copy Markdown

Linkable.key defaults to 0n, but all()/findnext used key === 0n as the bucket-sentinel marker. So a real entry keyed 0n — and anything inserted behind it in the same bucket — was skipped by all(), even though find() (which terminates on sentinel identity) still returned it.

const t = new HashTable(8);
t.add(0n, a); t.add(8n, b);   // both hash to bucket 0
[...t.all()]                  // [] — misses both
t.find(0n) === a              // true

Fix: iterate all() by sentinel identity like find() already does, and drop the now-unused findnext. 0n becomes a valid key.

0n is a valid key (Linkable.key defaults to 0n) but all()/findnext used it as
the bucket-sentinel marker, so a 0n entry and anything behind it in its bucket
were skipped (find() still returned them). Iterate by sentinel identity.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ejtriple

Copy link
Copy Markdown
Author

Closing - Probably need to revisit IPv6 handling instead of this approach. Now two people (with different ips) will be mapped to the same player, which is no bueno.

@ejtriple ejtriple closed this Jul 17, 2026
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