MCPcopy Create free account
hub / github.com/cantabular/faststringmap / LookupString

Method LookupString

uint32_store.go:130–144  ·  view source on GitHub ↗

LookupString looks up the supplied string in the map

(s string)

Source from the content-addressed store, hash-verified

128
129// LookupString looks up the supplied string in the map
130func (m *Uint32Store) LookupString(s string) (uint32, bool) {
131 bv := &m.store[0]
132 for i, n := 0, len(s); i < n; i++ {
133 b := s[i]
134 if b < bv.nextOffset {
135 return 0, false
136 }
137 ni := b - bv.nextOffset
138 if ni >= bv.nextLen {
139 return 0, false
140 }
141 bv = &m.store[bv.nextLo+uint32(ni)]
142 }
143 return bv.value, bv.valid
144}
145
146// LookupBytes looks up the supplied byte slice in the map
147func (m *Uint32Store) LookupBytes(s []byte) (uint32, bool) {

Callers 3

ExampleFunction · 0.95
checkWithMapSliceFunction · 0.95
BenchmarkUint32StoreFunction · 0.95

Calls

no outgoing calls

Tested by 3

ExampleFunction · 0.76
checkWithMapSliceFunction · 0.76
BenchmarkUint32StoreFunction · 0.76