@@ -8,28 +8,33 @@ package css
88// Hash defines perfect hashes for a predefined list of strings
99type Hash uint32
1010
11- // Unique hash definitions to be used instead of strings
11+ // Identifiers for the hashes associated with the text in the comments.
1212const (
1313 Document Hash = 0x8 // document
1414 Font_Face Hash = 0x809 // font-face
1515 Keyframes Hash = 0x1109 // keyframes
16- Media Hash = 0x2105 // media
17- Page Hash = 0x2604 // page
16+ Layer Hash = 0x2105 // layer
17+ Media Hash = 0x2605 // media
18+ Page Hash = 0x2b04 // page
1819 Supports Hash = 0x1908 // supports
1920)
2021
21- // String returns the hash' name .
22+ // String returns the text associated with the hash .
2223func (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 {
2329 start := uint32 (i >> 8 )
2430 n := uint32 (i & 0xff )
2531 if start + n > uint32 (len (_Hash_text )) {
26- return ""
32+ return [] byte {}
2733 }
2834 return _Hash_text [start : start + n ]
2935}
3036
31- // ToHash returns the hash whose name is s. It returns zero if there is no
32- // such hash. It is case sensitive.
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.
3338func ToHash (s []byte ) Hash {
3439 if len (s ) == 0 || len (s ) > _Hash_maxLen {
3540 return 0
@@ -61,15 +66,18 @@ NEXT:
6166 return 0
6267}
6368
64- const _Hash_hash0 = 0x9acb0442
69+ const _Hash_hash0 = 0x5aebcbca
6570const _Hash_maxLen = 9
66- const _Hash_text = "documentfont-facekeyframesupportsmediapage"
71+
72+ var _Hash_text = []byte ("" +
73+ "documentfont-facekeyframesupportslayermediapage" )
6774
6875var _Hash_table = [1 << 3 ]Hash {
69- 0x1 : 0x2604 , // page
70- 0x2 : 0x2105 , // media
76+ 0x0 : 0x1109 , // keyframes
77+ 0x1 : 0x2b04 , // page
78+ 0x2 : 0x2605 , // media
7179 0x3 : 0x809 , // font-face
72- 0x5 : 0x1109 , // keyframes
80+ 0x4 : 0x8 , // document
7381 0x6 : 0x1908 , // supports
74- 0x7 : 0x8 , // document
82+ 0x7 : 0x2105 , // layer
7583}
0 commit comments