1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 type valueRange struct {
8 value uint16 // header: value:stride
9 lo, hi byte // header: lo:n
12 type sparseBlocks struct {
17 var nfcSparse = sparseBlocks{
18 values: nfcSparseValues[:],
19 offset: nfcSparseOffset[:],
22 var nfkcSparse = sparseBlocks{
23 values: nfkcSparseValues[:],
24 offset: nfkcSparseOffset[:],
28 nfcData = newNfcTrie(0)
29 nfkcData = newNfkcTrie(0)
32 // lookupValue determines the type of block n and looks up the value for b.
33 // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
34 // is a list of ranges with an accompanying value. Given a matching range r,
35 // the value for b is by r.value + (b - r.lo) * stride.
36 func (t *sparseBlocks) lookup(n uint32, b byte) uint16 {
38 header := t.values[offset]
40 hi := lo + uint16(header.lo)
44 if r.lo <= b && b <= r.hi {
45 return r.value + uint16(b-r.lo)*header.value