-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
We have several helper methods in profiles that allow manipulating dictionary indices:
- PutAttribute(table KeyValueAndUnitSlice, record attributable, dic ProfilesDictionary, ...) error
- PutLocation(table LocationSlice, record Stack, loc Location) error
- SetFunction(table FunctionSlice, record Line, fn Function) error
- SetLink(table LinkSlice, record Sample, li Link) error
- SetMapping(table MappingSlice, record Location, ma Mapping) error
- SetString(table pcommon.StringSlice, val string) (int32, error)
- SetStack(table StackSlice, st Stack) (int32, error)
We should harmonize those methods so they all have similar signatures.
Right now, some are named PutX, and others are named SetX. I suggest we name everything SetX.
Right now, some methods take a record and update it in place, while others return the ID of the data that was retrieved or added to the dictionary.
Updating in place is not the most efficient way to do this, especially for merging profiles, as for slices of records (for example, attributes in a stack), we need to create a new slice and use the helper method on it.
If we return an ID, we can update the ID directly within the existing slice.
So I suggest we switch every helper method to use the signature of returning an ID (as SetString does).