Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(117)

Delta Between Two Patch Sets: publicsuffix/list.go

Issue 6999045: code review 6999045: go.net/publicsuffix: tighten the encoding from 8 bytes ... (Closed)
Left Patch Set: Created 12 years, 3 months ago
Right Patch Set: diff -r b0dd3b602c14 https://code.google.com/p/go.net Created 12 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « publicsuffix/gen.go ('k') | publicsuffix/list_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package publicsuffix provides a public suffix list based on data from 5 // Package publicsuffix provides a public suffix list based on data from
6 // http://publicsuffix.org/. A public suffix is one under which Internet users 6 // http://publicsuffix.org/. A public suffix is one under which Internet users
7 // can directly register names. 7 // can directly register names.
8 package publicsuffix 8 package publicsuffix
9 9
10 // TODO(nigeltao): do we need to distinguish between ICANN domains and private 10 // TODO(nigeltao): do we need to distinguish between ICANN domains and private
(...skipping 24 matching lines...) Expand all
35 suffix = 1 + dot 35 suffix = 1 + dot
36 } 36 }
37 if lo == hi { 37 if lo == hi {
38 break 38 break
39 } 39 }
40 f := find(s[1+dot:], lo, hi) 40 f := find(s[1+dot:], lo, hi)
41 if f == notFound { 41 if f == notFound {
42 break 42 break
43 } 43 }
44 44
45 » » u := nodes[f][0] 45 » » u := nodes[f] >> (nodesBitsTextOffset + nodesBitsTextLength)
46 » » lo = u & 0xffff 46 » » switch u & (1<<nodesBitsNodeType - 1) {
47 » » u >>= 16
48 » » hi = u&0x1fff + lo
49 » » u >>= 13
50 » » wildcard = u&0x01 != 0
51 » » u >>= 1
52 » » switch u {
53 case nodeTypeNormal: 47 case nodeTypeNormal:
54 suffix = 1 + dot 48 suffix = 1 + dot
55 case nodeTypeException: 49 case nodeTypeException:
56 suffix = 1 + len(s) 50 suffix = 1 + len(s)
57 break loop 51 break loop
58 } 52 }
53 u >>= nodesBitsNodeType
54
55 u = children[u&(1<<nodesBitsChildren-1)]
56 lo = u & (1<<childrenBitsLo - 1)
57 u >>= childrenBitsLo
58 hi = u & (1<<childrenBitsHi - 1)
59 u >>= childrenBitsHi
60 wildcard = u&(1<<childrenBitsWildcard-1) != 0
59 61
60 if dot == -1 { 62 if dot == -1 {
61 break 63 break
62 } 64 }
63 s = s[:dot] 65 s = s[:dot]
64 } 66 }
65 if suffix == len(domain) { 67 if suffix == len(domain) {
66 // If no rules match, the prevailing rule is "*". 68 // If no rules match, the prevailing rule is "*".
67 return domain[1+strings.LastIndex(domain, "."):] 69 return domain[1+strings.LastIndex(domain, "."):]
68 } 70 }
(...skipping 15 matching lines...) Expand all
84 return mid 86 return mid
85 } else { 87 } else {
86 hi = mid 88 hi = mid
87 } 89 }
88 } 90 }
89 return notFound 91 return notFound
90 } 92 }
91 93
92 // nodeLabel returns the label for the i'th node. 94 // nodeLabel returns the label for the i'th node.
93 func nodeLabel(i uint32) string { 95 func nodeLabel(i uint32) string {
94 » x := nodes[i][1] 96 » x := nodes[i]
95 » offset, length := x>>8, x&0xff 97 » length := x & (1<<nodesBitsTextLength - 1)
98 » x >>= nodesBitsTextLength
99 » offset := x & (1<<nodesBitsTextOffset - 1)
96 return text[offset : offset+length] 100 return text[offset : offset+length]
97 } 101 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b