Debian Codegraph @

css/hash.go

raw
1 package css
2
3 // generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate
4
5 // uses github.com/tdewolff/hasher
6 //go:generate hasher -type=Hash -file=hash.go
7
8 // Hash defines perfect hashes for a predefined list of strings
9 type Hash uint32
10
11 // Identifiers for the hashes associated with the text in the comments.
12 const (
13 Document Hash = 0x8 // document
14 Font_Face Hash = 0x809 // font-face
15 Keyframes Hash = 0x1109 // keyframes
16 Layer Hash = 0x2105 // layer
17 Media Hash = 0x2605 // media
18 Page Hash = 0x2b04 // page
19 Supports Hash = 0x1908 // supports
20 )
21
22 // String returns the text associated with the hash.
23 func (i Hash) String() string {
24 return string(i.Bytes())
25 }
26
27 // Bytes returns the text associated with the hash.
28 func (i Hash) Bytes() []byte {
29 start := uint32(i >> 8)
30 n := uint32(i & 0xff)
31 if start+n > uint32(len(_Hash_text)) {
32 return []byte{}
33 }
34 return _Hash_text[start : start+n]
35 }
36
37 // ToHash returns a hash Hash for a given []byte. Hash is a uint32 that is associated with the text in []byte. It returns zero if no match found.
38 func ToHash(s []byte) Hash {
39 if len(s) == 0 || len(s) > _Hash_maxLen {
40 return 0
41 }
42 h := uint32(_Hash_hash0)
43 for i := 0; i < len(s); i++ {
44 h ^= uint32(s[i])
45 h *= 16777619
46 }
47 if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
48 t := _Hash_text[i>>8 : i>>8+i&0xff]
49 for i := 0; i < len(s); i++ {
50 if t[i] != s[i] {
51 goto NEXT
52 }
53 }
54 return i
55 }
56 NEXT:
57 if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) {
58 t := _Hash_text[i>>8 : i>>8+i&0xff]
59 for i := 0; i < len(s); i++ {
60 if t[i] != s[i] {
61 return 0
62 }
63 }
64 return i
65 }
66 return 0
67 }
68
69 const _Hash_hash0 = 0x5aebcbca
70 const _Hash_maxLen = 9
71
72 var _Hash_text = []byte("" +
73 "documentfont-facekeyframesupportslayermediapage")
74
75 var _Hash_table = [1 << 3]Hash{
76 0x0: 0x1109, // keyframes
77 0x1: 0x2b04, // page
78 0x2: 0x2605, // media
79 0x3: 0x809, // font-face
80 0x4: 0x8, // document
81 0x6: 0x1908, // supports
82 0x7: 0x2105, // layer
83 }