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
When calling Foreach() on the tag.Map, we gain access to every key and value in the map. We can also use Value() to get access to a value for a specific key. The keys and values returned should essentially be copies of whatever is contained in the map, and usually they are. There are some troublesome members though. Some of them have the pointer-like semantics, so it is possible to mutate them in the Foreach callback or just in the returned object from Value(), and thus mutate the contents of the map itself.
Currently that happens for the keys in the map that contain the BYTES Value. So the map implementation should make a copy of the bytes when giving the access to it.
I'm also wondering if the Type field in registry.Variable should also be copied, because it is an interface, so it also could have some pointer-like semantics when doing shallow copy during Foreach.
The text was updated successfully, but these errors were encountered:
When calling
Foreach()
on thetag.Map
, we gain access to every key and value in the map. We can also useValue()
to get access to a value for a specific key. The keys and values returned should essentially be copies of whatever is contained in the map, and usually they are. There are some troublesome members though. Some of them have the pointer-like semantics, so it is possible to mutate them in theForeach
callback or just in the returned object fromValue()
, and thus mutate the contents of the map itself.Currently that happens for the keys in the map that contain the BYTES Value. So the map implementation should make a copy of the bytes when giving the access to it.
I'm also wondering if the
Type
field inregistry.Variable
should also be copied, because it is an interface, so it also could have some pointer-like semantics when doing shallow copy duringForeach
.The text was updated successfully, but these errors were encountered: