Don't sort map keys when encoding a map field in wire format.
This was a miscommunication; I heard that the map keys were meant
to be sorted, but that statement was only meant to apply to the
text format. With this change we match the C++ behaviour.
Fixes #86.
diff --git a/proto/encode.go b/proto/encode.go
index 89d0caa..7321e1a 100644
--- a/proto/encode.go
+++ b/proto/encode.go
@@ -1115,9 +1115,8 @@
return nil
}
- keys := v.MapKeys()
- sort.Sort(mapKeys(keys))
- for _, key := range keys {
+ // Don't sort map keys. It is not required by the spec, and C++ doesn't do it.
+ for _, key := range v.MapKeys() {
val := v.MapIndex(key)
// The only illegal map entry values are nil message pointers.