Commit 5afa271c authored by Marcel van Lohuizen's avatar Marcel van Lohuizen

exp/locale/collate: several changes based on comments on CL 7060051

which was submitted earlier.

R=r
CC=golang-dev
https://golang.org/cl/7402048
parent f853e9aa
......@@ -35,15 +35,6 @@ func (s *sorter) init(n int) {
s.keys = s.keys[0:n]
}
func (s *sorter) clean() {
if len(s.buf.key) > maxSortBuffer {
s.buf.key = s.buf.buf[:0]
}
if len(s.keys) > maxSortEntries {
s.keys = nil
}
}
func (s *sorter) sort(src swapper) {
s.src = src
sort.Sort(s)
......@@ -80,8 +71,8 @@ func (c *Collator) Sort(x Lister) {
c.sorter.sort(x)
}
// Strings sorts x using the rules of c.
func (c *Collator) Strings(x []string) {
// SortStrings uses sort.Sort to sort the strings in x using the rules of c.
func (c *Collator) SortStrings(x []string) {
c.sorter.init(len(x))
for i, s := range x {
c.sorter.keys[i] = c.KeyFromString(c.sorter.buf, s)
......
......@@ -14,12 +14,13 @@ func ExampleCollator_Strings() {
c := collate.New("root")
strings := []string{
"ad",
"ab",
"äb",
"ac",
}
c.Strings(strings)
c.SortStrings(strings)
fmt.Println(strings)
// Output: [äb ac ad]
// Output: [ab äb ac ad]
}
type sorter []string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment