X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libgo%2Fgo%2Fexp%2Fnorm%2Ftriegen.go;h=52c88b039a2495ebef7bbf2a8ff130c15e35940e;hb=4d8cd3a26294ce35abb17668eac2b6c38dd23bd0;hp=2e275a06254f56a142af4aef313b7a9ea368bb51;hpb=c944d49b3bd3667c65c299afd3b1d756084203f4;p=platform%2Fupstream%2Fgcc48.git diff --git a/libgo/go/exp/norm/triegen.go b/libgo/go/exp/norm/triegen.go index 2e275a0..52c88b0 100644 --- a/libgo/go/exp/norm/triegen.go +++ b/libgo/go/exp/norm/triegen.go @@ -19,8 +19,11 @@ import ( "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 { @@ -157,7 +160,7 @@ func computeOffsets(index *nodeIndex, n *trieNode) int { 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 } @@ -166,7 +169,7 @@ func computeOffsets(index *nodeIndex, n *trieNode) int { 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 { @@ -295,7 +298,7 @@ func (t *trieNode) printTables(name string) int { } 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")