Explorar o código

jsonpb: avoid copying string-valued map-keys (#654)

David Howden %!s(int64=7) %!d(string=hai) anos
pai
achega
14aad3d5ea
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      jsonpb/jsonpb.go

+ 2 - 0
jsonpb/jsonpb.go

@@ -1116,6 +1116,8 @@ func (s mapKeys) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
 func (s mapKeys) Less(i, j int) bool {
 func (s mapKeys) Less(i, j int) bool {
 	if k := s[i].Kind(); k == s[j].Kind() {
 	if k := s[i].Kind(); k == s[j].Kind() {
 		switch k {
 		switch k {
+		case reflect.String:
+			return s[i].String() < s[j].String()
 		case reflect.Int32, reflect.Int64:
 		case reflect.Int32, reflect.Int64:
 			return s[i].Int() < s[j].Int()
 			return s[i].Int() < s[j].Int()
 		case reflect.Uint32, reflect.Uint64:
 		case reflect.Uint32, reflect.Uint64: