File tree 1 file changed +7
-7
lines changed 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,14 @@ import (
19
19
)
20
20
21
21
// Collator provides functionality for comparing strings for a given
22
- // collation order.
22
+ // collation order. A given Collator is not safe to use concurrently.
23
23
type Collator struct {
24
24
options
25
25
26
26
sorter sorter
27
27
28
+ buf Buffer
29
+
28
30
_iter [2 ]iter
29
31
}
30
32
@@ -106,9 +108,8 @@ func (b *Buffer) Reset() {
106
108
// a new buffer will be allocated for each call.
107
109
func (c * Collator ) Compare (a , b []byte ) int {
108
110
var (
109
- buf Buffer
110
- kA = c .Key (& buf , a )
111
- kB = c .Key (& buf , b )
111
+ kA
935C
span> = c .Key (& c .buf , a )
112
+ kB = c .Key (& c .buf , b )
112
113
)
113
114
return bytes .Compare (kA , kB )
114
115
}
@@ -119,9 +120,8 @@ func (c *Collator) Compare(a, b []byte) int {
119
120
// a new buffer will be allocated for each call.
120
121
func (c * Collator ) CompareString (a , b string ) int {
121
122
var (
122
- buf Buffer
123
- kA = c .KeyFromString (& buf , a )
124
- kB = c .KeyFromString (& buf , b )
123
+ kA = c .KeyFromString (& c .buf , a )
124
+ kB = c .KeyFromString (& c .buf , b )
125
125
)
126
126
return bytes .Compare (kA , kB )
127
127
}
You can’t perform that action at this time.
0 commit comments