From 5afa271ce35f6f4bdd55569dd7c7ade63523887a Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Wed, 27 Feb 2013 11:08:18 +0100 Subject: [PATCH] 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 --- src/pkg/exp/locale/collate/sort.go | 13 ++----------- src/pkg/exp/locale/collate/sort_test.go | 5 +++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/pkg/exp/locale/collate/sort.go b/src/pkg/exp/locale/collate/sort.go index 57b2efdfc2..62f1e75a3c 100644 --- a/src/pkg/exp/locale/collate/sort.go +++ b/src/pkg/exp/locale/collate/sort.go @@ -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) diff --git a/src/pkg/exp/locale/collate/sort_test.go b/src/pkg/exp/locale/collate/sort_test.go index d0682f48e6..49b18b8b3f 100644 --- a/src/pkg/exp/locale/collate/sort_test.go +++ b/src/pkg/exp/locale/collate/sort_test.go @@ -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 -- 2.48.1