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

Function uint32Build

uint32_store.go:53–66  ·  view source on GitHub ↗

uint32Build constructs the map by allocating memory in blocks and then copying into the eventual slice at the end. This is more efficient than continually using append.

(keys []string, src Uint32Source)

Source from the content-addressed store, hash-verified

51// and then copying into the eventual slice at the end. This is
52// more efficient than continually using append.
53func uint32Build(keys []string, src Uint32Source) []byteValue {
54 b := uint32Builder{
55 all: [][]byteValue{make([]byteValue, 1, firstBufSize(len(keys)))},
56 src: src,
57 len: 1,
58 }
59 b.makeByteValue(&b.all[0][0], keys, 0)
60 // copy all blocks to one slice
61 s := make([]byteValue, 0, b.len)
62 for _, a := range b.all {
63 s = append(s, a...)
64 }
65 return s
66}
67
68// makeByteValue will initialise the supplied byteValue for
69// the sorted strings in slice a considering bytes at byteIndex in the strings

Callers 1

NewUint32StoreFunction · 0.85

Calls 2

makeByteValueMethod · 0.95
firstBufSizeFunction · 0.85

Tested by

no test coverage detected