Advertisement
Guest User

Untitled

a guest
Jan 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 0.81 KB | None | 0 0
  1. diff --git a/vendor/src/gopkg.in/yaml.v2/decode.go b/vendor/src/gopkg.in/yaml.v2/decode.go
  2. index e85eb2e..01ec24f 100644
  3. --- a/vendor/src/gopkg.in/yaml.v2/decode.go
  4. +++ b/vendor/src/gopkg.in/yaml.v2/decode.go
  5. @@ -559,9 +559,17 @@ func (d *decoder) mapping(n *node, out reflect.Value) (good bool) {
  6.             if kkind == reflect.Map || kkind == reflect.Slice {
  7.                 failf("invalid map key: %#v", k.Interface())
  8.             }
  9. -           e := reflect.New(et).Elem()
  10. -           if d.unmarshal(n.children[i+1], e) {
  11. -               out.SetMapIndex(k, e)
  12. +           e := out.MapIndex(k)
  13. +           if e.IsValid() {
  14. +               // Reuse map entry.
  15. +               e = e.Elem()
  16. +               d.unmarshal(n.children[i+1], e)
  17. +           } else {
  18. +               // Add new map entry.
  19. +               e := reflect.New(et).Elem()
  20. +               if d.unmarshal(n.children[i+1], e) {
  21. +                   out.SetMapIndex(k, e)
  22. +               }
  23.             }
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement