aboutsummaryrefslogtreecommitdiff
path: root/cmp/compare.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2017-07-07 16:30:14 -0700
committerGitHub <noreply@github.com>2017-07-07 16:30:14 -0700
commit5c2f3415b05eca653272685cb8b1fdf4acfb6cd6 (patch)
tree4f46f4a62342e6d9020a9410cb8e6df948f83ee5 /cmp/compare.go
parentdf565aecfca1377a64c83df6fb3bc0b7bad9c6f4 (diff)
downloadgo-cmp-5c2f3415b05eca653272685cb8b1fdf4acfb6cd6.tar.gz
Support versions of Go down to Go1.6 (#3)
Avoid any features introduced in newer versions such as: * testing.T.Run * sort.Slice * sort.SliceStable * sort.IsSliceSorted Fixes #2
Diffstat (limited to 'cmp/compare.go')
-rw-r--r--cmp/compare.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/cmp/compare.go b/cmp/compare.go
index 0d8ef77..455ecb8 100644
--- a/cmp/compare.go
+++ b/cmp/compare.go
@@ -28,7 +28,6 @@ package cmp
import (
"fmt"
"reflect"
- "sort"
)
// BUG: Maps with keys containing NaN values cannot be properly compared due to
@@ -126,10 +125,13 @@ func newState(opts []Option) *state {
for _, opt := range opts {
s.processOption(opt)
}
- // Sort options such that Ignore options are evaluated first.
- sort.SliceStable(s.opts, func(i, j int) bool {
- return s.opts[i].op == nil && s.opts[j].op != nil
- })
+ // Move Ignore options to the front so that they are evaluated first.
+ for i, j := 0, 0; i < len(s.opts); i++ {
+ if s.opts[i].op == nil {
+ s.opts[i], s.opts[j] = s.opts[j], s.opts[i]
+ j++
+ }
+ }
return s
}