You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pcommon.Map.Insert/Update/Upsert are the only methods allowing setting the mutable types on the Map. This practice is generaly discouraged in pdata module since it potentially can lead to setting the same maps/slices across different parts of pdata.
Setting mutable types should be replaced with other methods, e.g. Map.UpsertEmpty() Value.
The text was updated successfully, but these errors were encountered:
@bogdandrutu I realized all the Upsert/Insert/Update methods copy the underlying data under the hood. It means that my concern about sharing the same objects in different parts of pdata is invalid. But it means that the only way to put a map or a slice as a child of another map is to generate a map and copy it, which always implies another extra allocation for the whole map.
childMap:=NewValueMap()
...fillchildMap...parentMap.Upsert("key", childMap) // childMap is copied here
If we move to UpsertEmptyMap, we don't have any extra allocations
pcommon.Map.Insert/Update/Upsert
are the only methods allowing setting the mutable types on the Map. This practice is generaly discouraged in pdata module since it potentially can lead to setting the same maps/slices across different parts of pdata.Setting mutable types should be replaced with other methods, e.g.
Map.UpsertEmpty() Value
.The text was updated successfully, but these errors were encountered: