revert: forgot about b -> t
Some checks failed
CI / Check PR Title (pull_request) Successful in 31s
CI / Makefile Lint (pull_request) Successful in 50s
CI / Go Lint (pull_request) Successful in 55s
CI / Markdown Lint (pull_request) Successful in 34s
CI / Unit Tests (pull_request) Successful in 49s
CI / Fuzz Tests (pull_request) Failing after 41s
CI / Mutation Tests (pull_request) Successful in 1m1s

This commit is contained in:
2026-04-16 00:00:37 -04:00
parent 1f7c64366d
commit 78f7d01d5f

View File

@@ -20,52 +20,52 @@ type subtable[K, V any] struct {
// location determines where in the bucket a certain key would be placed. If the
// capacity is 0, this will panic.
func (b *subtable[K, V]) location(key K) uint64 {
return b.hash(key) % b.capacity
func (t *subtable[K, V]) location(key K) uint64 {
return t.hash(key) % t.capacity
}
func (b *subtable[K, V]) get(key K) (value V, found bool) {
if b.capacity == 0 {
func (t *subtable[K, V]) get(key K) (value V, found bool) {
if t.capacity == 0 {
return
}
slot := b.slots[b.location(key)]
return slot.Value, slot.occupied && b.compare(slot.Key, key)
slot := t.slots[t.location(key)]
return slot.Value, slot.occupied && t.compare(slot.Key, key)
}
func (b *subtable[K, V]) drop(key K) (occupied bool) {
if b.capacity == 0 {
func (t *subtable[K, V]) drop(key K) (occupied bool) {
if t.capacity == 0 {
return
}
slot := &b.slots[b.location(key)]
slot := &t.slots[t.location(key)]
if slot.occupied && b.compare(slot.Key, key) {
if slot.occupied && t.compare(slot.Key, key) {
slot.occupied = false
b.size--
t.size--
return true
}
return false
}
func (b *subtable[K, V]) resized(capacity uint64) *subtable[K, V] {
func (t *subtable[K, V]) resized(capacity uint64) *subtable[K, V] {
return &subtable[K, V]{
slots: make([]slot[K, V], capacity),
capacity: capacity,
hash: b.hash,
compare: b.compare,
hash: t.hash,
compare: t.compare,
}
}
func (b *subtable[K, V]) update(key K, value V) (updated bool) {
if b.capacity == 0 {
func (t *subtable[K, V]) update(key K, value V) (updated bool) {
if t.capacity == 0 {
return
}
slot := &b.slots[b.location(key)]
slot := &t.slots[t.location(key)]
if slot.occupied && b.compare(slot.Key, key) {
if slot.occupied && t.compare(slot.Key, key) {
slot.Value = value
return true
}
@@ -73,21 +73,21 @@ func (b *subtable[K, V]) update(key K, value V) (updated bool) {
return false
}
func (b *subtable[K, V]) insert(insertion Entry[K, V]) (evicted Entry[K, V], eviction bool) {
if b.capacity == 0 {
func (t *subtable[K, V]) insert(insertion Entry[K, V]) (evicted Entry[K, V], eviction bool) {
if t.capacity == 0 {
return insertion, true
}
slot := &b.slots[b.location(insertion.Key)]
slot := &t.slots[t.location(insertion.Key)]
if !slot.occupied {
slot.Entry = insertion
slot.occupied = true
b.size++
t.size++
return
}
if b.compare(slot.Key, insertion.Key) {
if t.compare(slot.Key, insertion.Key) {
slot.Value = insertion.Value
return
}