diff options
Diffstat (limited to 'vendor/github.com/tdewolff/parse/v2/html/hash.go')
-rw-r--r-- | vendor/github.com/tdewolff/parse/v2/html/hash.go | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/vendor/github.com/tdewolff/parse/v2/html/hash.go b/vendor/github.com/tdewolff/parse/v2/html/hash.go deleted file mode 100644 index 16432ade1..000000000 --- a/vendor/github.com/tdewolff/parse/v2/html/hash.go +++ /dev/null @@ -1,81 +0,0 @@ -package html - -// generated by hasher -type=Hash -file=hash.go; DO NOT EDIT, except for adding more constants to the list and rerun go generate - -// uses github.com/tdewolff/hasher -//go:generate hasher -type=Hash -file=hash.go - -// Hash defines perfect hashes for a predefined list of strings -type Hash uint32 - -// Unique hash definitions to be used instead of strings -const ( - Iframe Hash = 0x6 // iframe - Math Hash = 0x604 // math - Plaintext Hash = 0x1e09 // plaintext - Script Hash = 0xa06 // script - Style Hash = 0x1405 // style - Svg Hash = 0x1903 // svg - Textarea Hash = 0x2308 // textarea - Title Hash = 0xf05 // title - Xmp Hash = 0x1c03 // xmp -) - -// String returns the hash' name. -func (i Hash) String() string { - start := uint32(i >> 8) - n := uint32(i & 0xff) - if start+n > uint32(len(_Hash_text)) { - return "" - } - return _Hash_text[start : start+n] -} - -// ToHash returns the hash whose name is s. It returns zero if there is no -// such hash. It is case sensitive. -func ToHash(s []byte) Hash { - if len(s) == 0 || len(s) > _Hash_maxLen { - return 0 - } - h := uint32(_Hash_hash0) - for i := 0; i < len(s); i++ { - h ^= uint32(s[i]) - h *= 16777619 - } - if i := _Hash_table[h&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) { - t := _Hash_text[i>>8 : i>>8+i&0xff] - for i := 0; i < len(s); i++ { - if t[i] != s[i] { - goto NEXT - } - } - return i - } -NEXT: - if i := _Hash_table[(h>>16)&uint32(len(_Hash_table)-1)]; int(i&0xff) == len(s) { - t := _Hash_text[i>>8 : i>>8+i&0xff] - for i := 0; i < len(s); i++ { - if t[i] != s[i] { - return 0 - } - } - return i - } - return 0 -} - -const _Hash_hash0 = 0x9acb0442 -const _Hash_maxLen = 9 -const _Hash_text = "iframemathscriptitlestylesvgxmplaintextarea" - -var _Hash_table = [1 << 4]Hash{ - 0x0: 0x2308, // textarea - 0x2: 0x6, // iframe - 0x4: 0xf05, // title - 0x5: 0x1e09, // plaintext - 0x7: 0x1405, // style - 0x8: 0x604, // math - 0x9: 0xa06, // script - 0xa: 0x1903, // svg - 0xb: 0x1c03, // xmp -} |