mapelem.go 573 B

12345678910111213141516171819202122
  1. // +build go1.12
  2. package fmtsort
  3. import "reflect"
  4. const brokenNaNs = false
  5. func mapElems(mapValue reflect.Value) ([]reflect.Value, []reflect.Value) {
  6. // Note: this code is arranged to not panic even in the presence
  7. // of a concurrent map update. The runtime is responsible for
  8. // yelling loudly if that happens. See issue 33275.
  9. n := mapValue.Len()
  10. key := make([]reflect.Value, 0, n)
  11. value := make([]reflect.Value, 0, n)
  12. iter := mapValue.MapRange()
  13. for iter.Next() {
  14. key = append(key, iter.Key())
  15. value = append(value, iter.Value())
  16. }
  17. return key, value
  18. }