Commit 628403fd authored by Seebs's avatar Seebs Committed by Brad Fitzpatrick

text/template: drop unused sortKeys function

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/143178Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent ae0c4358
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
"io" "io"
"reflect" "reflect"
"runtime" "runtime"
"sort"
"strings" "strings"
"text/template/parse" "text/template/parse"
) )
...@@ -960,29 +959,3 @@ func printableValue(v reflect.Value) (interface{}, bool) { ...@@ -960,29 +959,3 @@ func printableValue(v reflect.Value) (interface{}, bool) {
} }
return v.Interface(), true 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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment