mapelem.go 555 B

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