]> Cypherpunks repositories - gostls13.git/commitdiff
text/template: drop unused sortKeys function
authorSeebs <seebachp@gmail.com>
Thu, 18 Oct 2018 22:00:02 +0000 (17:00 -0500)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 19 Oct 2018 05:17:57 +0000 (05:17 +0000)
Recent change golang.org/cl/142737 drops the only call site for the
sortKeys function. If it's not in use, it should probably not be there in
the code, lurking and preparing to bite us when someone calls that instead
of the new key sorter in fmtsort, resulting in strange inconsistencies.

Since the function isn't called, this should have no impact.
Related to, but does not fix, #21095.

Change-Id: I4695503ef4d5ce90d989ec952f01ea00cc15c79d
Reviewed-on: https://go-review.googlesource.com/c/143178
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/text/template/exec.go

index 120d010a19ae0b7aeaea7de0f726733b74c75f75..36cea3d24db9f2136a3731771c2e8faeb76fca8b 100644 (file)
@@ -11,7 +11,6 @@ import (
        "io"
        "reflect"
        "runtime"
-       "sort"
        "strings"
        "text/template/parse"
 )
@@ -960,29 +959,3 @@ func printableValue(v reflect.Value) (interface{}, bool) {
        }
        return v.Interface(), true
 }
-
-// sortKeys sorts (if it can) the slice of reflect.Values, which is a slice of map keys.
-func sortKeys(v []reflect.Value) []reflect.Value {
-       if len(v) <= 1 {
-               return v
-       }
-       switch v[0].Kind() {
-       case reflect.Float32, reflect.Float64:
-               sort.Slice(v, func(i, j int) bool {
-                       return v[i].Float() < v[j].Float()
-               })
-       case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-               sort.Slice(v, func(i, j int) bool {
-                       return v[i].Int() < v[j].Int()
-               })
-       case reflect.String:
-               sort.Slice(v, func(i, j int) bool {
-                       return v[i].String() < v[j].String()
-               })
-       case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
-               sort.Slice(v, func(i, j int) bool {
-                       return v[i].Uint() < v[j].Uint()
-               })
-       }
-       return v
-}