From: Seebs Date: Thu, 18 Oct 2018 22:00:02 +0000 (-0500) Subject: text/template: drop unused sortKeys function X-Git-Tag: go1.12beta1~719 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=628403fd6b02a8e71926b0cbc7c893121482628a;p=gostls13.git 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/143178 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/text/template/exec.go b/src/text/template/exec.go index 120d010a19..36cea3d24d 100644 --- a/src/text/template/exec.go +++ b/src/text/template/exec.go @@ -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 -}