...
1
2
3
4
5
6
7
8
9
10
11 package runenames
12
13 import (
14 "sort"
15 )
16
17
18 func Name(r rune) string {
19 i := sort.Search(len(entries), func(j int) bool {
20 return entries[j].startRune() > r
21 })
22 if i == 0 {
23 return ""
24 }
25 e := entries[i-1]
26
27 offset := int(r - e.startRune())
28 if offset >= e.numRunes() {
29 return ""
30 }
31
32 if e.direct() {
33 o := e.index()
34 n := e.len()
35 return directData[o : o+n]
36 }
37
38 start := int(index[e.index()+offset])
39 end := int(index[e.index()+offset+1])
40 base1 := e.base() << 16
41 base2 := base1
42 if start > end {
43 base2 += 1 << 16
44 }
45 return singleData[start+base1 : end+base2]
46 }
47
48 func (e entry) len() int { return e.base() }
49
View as plain text