fix!: removed all 'mixed pointer'-edness
All checks were successful
CI / Check PR Title (pull_request) Successful in 31s
CI / Makefile Lint (pull_request) Successful in 45s
CI / Markdown Lint (pull_request) Successful in 34s
CI / Unit Tests (pull_request) Successful in 41s
CI / Go Lint (pull_request) Successful in 56s
CI / Fuzz Tests (pull_request) Successful in 1m39s
CI / Mutation Tests (pull_request) Successful in 1m5s

This commit is contained in:
2026-04-15 22:59:31 -04:00
parent ce41d4fba2
commit f35583e079
2 changed files with 12 additions and 12 deletions

View File

@@ -27,12 +27,12 @@ type Table[K, V any] struct {
// TotalCapacity returns the number of slots allocated for the [Table]. To get the
// number of slots filled, look at [Table.Size].
func (t Table[K, V]) TotalCapacity() uint64 {
func (t *Table[K, V]) TotalCapacity() uint64 {
return t.bucketA.capacity + t.bucketB.capacity
}
// Size returns how many slots are filled in the [Table].
func (t Table[K, V]) Size() int {
func (t *Table[K, V]) Size() int {
return int(t.bucketA.size + t.bucketB.size)
}
@@ -40,11 +40,11 @@ func log2(n uint64) (m int) {
return max(0, bits.Len64(n)-1)
}
func (t Table[K, V]) maxEvictions() int {
func (t *Table[K, V]) maxEvictions() int {
return 3 * log2(t.TotalCapacity())
}
func (t Table[K, V]) load() float64 {
func (t *Table[K, V]) load() float64 {
// When there are no slots in the table, we still treat the load as 100%.
// Every slot in the table is full.
if t.TotalCapacity() == 0 {
@@ -97,7 +97,7 @@ func (t *Table[K, V]) shrink() error {
// Get fetches the value for a key in the [Table]. Matches the comma-ok pattern
// of a builtin map; see [Table.Find] for plain indexing.
func (t Table[K, V]) Get(key K) (value V, ok bool) {
func (t *Table[K, V]) Get(key K) (value V, ok bool) {
if item, ok := t.bucketA.get(key); ok {
return item, true
}
@@ -111,13 +111,13 @@ func (t Table[K, V]) Get(key K) (value V, ok bool) {
// Find fetches the value of a key. Matches direct indexing of a builtin map;
// see [Table.Get] for a comma-ok pattern.
func (t Table[K, V]) Find(key K) (value V) {
func (t *Table[K, V]) Find(key K) (value V) {
value, _ = t.Get(key)
return
}
// Has returns true if a key has a value in the table.
func (t Table[K, V]) Has(key K) (exists bool) {
func (t *Table[K, V]) Has(key K) (exists bool) {
_, exists = t.Get(key)
return
}
@@ -168,7 +168,7 @@ func (t *Table[K, V]) Drop(key K) (err error) {
}
// Entries returns an unordered sequence of all key-value pairs in the table.
func (t Table[K, V]) Entries() iter.Seq2[K, V] {
func (t *Table[K, V]) Entries() iter.Seq2[K, V] {
return func(yield func(K, V) bool) {
for _, slot := range t.bucketA.slots {
if slot.occupied {
@@ -190,7 +190,7 @@ func (t Table[K, V]) Entries() iter.Seq2[K, V] {
// String returns the entries of the table as a string in the format:
// "table[k1:v1 h2:v2 ...]".
func (t Table[K, V]) String() string {
func (t *Table[K, V]) String() string {
var sb strings.Builder
sb.WriteString("table[")