"unicode/utf8"
)
-const blockSize = 64
-const maxSparseEntries = 16
+const (
+ blockSize = 64
+ blockOffset = 2 // Subtract two blocks to compensate for the 0x80 added to continuation bytes.
+ maxSparseEntries = 16
+)
// Intermediate trie structure
type trieNode struct {
if n.isInternal() {
v, ok := index.lookupBlockIdx[h]
if !ok {
- v = len(index.lookupBlocks)
+ v = len(index.lookupBlocks) - blockOffset
index.lookupBlocks = append(index.lookupBlocks, n)
index.lookupBlockIdx[h] = v
}
v, ok := index.valueBlockIdx[h]
if !ok {
if c := n.countSparseEntries(); c > maxSparseEntries {
- v = len(index.valueBlocks)
+ v = len(index.valueBlocks) - blockOffset
index.valueBlocks = append(index.valueBlocks, n)
index.valueBlockIdx[h] = v
} else {
}
fmt.Print("\n}\n\n")
- cutoff := len(index.valueBlocks)
+ cutoff := len(index.valueBlocks) - blockOffset
ni := len(index.lookupBlocks) * blockSize
fmt.Printf("// %sLookup: %d bytes\n", name, ni)
fmt.Printf("// Block 0 is the null block.\n")