language: remove compatibility with go < 1.2 This was added in 9f86e0be982f3e937cd7146d47f65a80d618e8bc to provide compatibility with go1.1, which is an obsolete version. Change-Id: Ie3edbf9bd377608344e14ba327c437cbc4aa0c9a GitHub-Last-Rev: a009d8c981cbb0948a93c4a01ce0d24bacf8ae1a GitHub-Pull-Request: golang/text#37 Reviewed-on: https://go-review.googlesource.com/c/text/+/442796 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
diff --git a/language/go1_1.go b/language/go1_1.go deleted file mode 100644 index c743558..0000000 --- a/language/go1_1.go +++ /dev/null
@@ -1,39 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.2 -// +build !go1.2 - -package language - -import "sort" - -func sortStable(s sort.Interface) { - ss := stableSort{ - s: s, - pos: make([]int, s.Len()), - } - for i := range ss.pos { - ss.pos[i] = i - } - sort.Sort(&ss) -} - -type stableSort struct { - s sort.Interface - pos []int -} - -func (s *stableSort) Len() int { - return len(s.pos) -} - -func (s *stableSort) Less(i, j int) bool { - return s.s.Less(i, j) || !s.s.Less(j, i) && s.pos[i] < s.pos[j] -} - -func (s *stableSort) Swap(i, j int) { - s.s.Swap(i, j) - s.pos[i], s.pos[j] = s.pos[j], s.pos[i] -}
diff --git a/language/go1_2.go b/language/go1_2.go deleted file mode 100644 index 77aaaa2..0000000 --- a/language/go1_2.go +++ /dev/null
@@ -1,12 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.2 -// +build go1.2 - -package language - -import "sort" - -var sortStable = sort.Stable
diff --git a/language/parse.go b/language/parse.go index b982d9e..4d57222 100644 --- a/language/parse.go +++ b/language/parse.go
@@ -6,6 +6,7 @@ import ( "errors" + "sort" "strconv" "strings" @@ -206,7 +207,7 @@ tag = append(tag, t) q = append(q, float32(w)) } - sortStable(&tagSort{tag, q}) + sort.Stable(&tagSort{tag, q}) return tag, q, nil }