]> Cypherpunks repositories - gostls13.git/commitdiff
exp/locale/collate: several changes based on comments on CL 7060051
authorMarcel van Lohuizen <mpvl@golang.org>
Wed, 27 Feb 2013 10:08:18 +0000 (11:08 +0100)
committerMarcel van Lohuizen <mpvl@golang.org>
Wed, 27 Feb 2013 10:08:18 +0000 (11:08 +0100)
which was submitted earlier.

R=r
CC=golang-dev
https://golang.org/cl/7402048

src/pkg/exp/locale/collate/sort.go
src/pkg/exp/locale/collate/sort_test.go

index 57b2efdfc258bc2a8d44d80eec337f5e99b1a2aa..62f1e75a3c4e70cb62ab0bed89e13644474a30e1 100644 (file)
@@ -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)
index d0682f48e6fb8f70f1b891b5a791b518543eb777..49b18b8b3fcd10eda447420f6c56b15a15715b4c 100644 (file)
@@ -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