-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
Milestone
Description
For most reflection operation, there is an allocation free way to walk a value tree. At present, there is no way to obtain the value of a map entry without allocating since reflect.Value.MapIndex allocates the underlying value on the heap (since map entries are unaddressable).
Assuming we can't do #57060, I propose an explicit API for setting an addressable value with the value of a map entry:
// SetMapIndexOf is equivalent to v.Set(m.MapIndex(k)).
func (v Value) SetMapIndexOf(m, k Value)The method is so named because the SetMapIndex method is already taken up for the operation equivalent to v[key] = elem. Alternative suggest names welcome.
bcmills, danteRivasR and mvdan
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Incoming