-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor copy of slices and maps #2128
Refactor copy of slices and maps #2128
Conversation
a9ef2aa
to
13a96fe
Compare
store.go
Outdated
options.BigData = copyContainerBigDataOptionSlice(cOptions.BigData) | ||
options.BigData = slices.Clone(cOptions.BigData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slices.Clone
makes a shallow clone, i.e. Data
slice is not really copied with this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous copyContainerBigDataOptionSlice
function used the slices.Clone
function to copy data. So I would expect similar behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used slices.Clone()
to copy the Data
field in each element in the slice. The godoc for slices.Clone()
notes that it only copies using assignment, so a new slice would not be created for Data
fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've reverted these changes.
/approved |
13a96fe
to
b1a1078
Compare
Removes duplicate copy*Slice functions using a generic copy function or replaces them with the slices.Clone function. Also simplifies the stringSliceWithoutValue function. These changes should not change the behavior. Signed-off-by: Jan Rodák <[email protected]>
Removes the duplicate copy*Map function using the general function newMapFrom. Reduces the allocation of empty maps using the copyMapPrefferingNil function. This change may affect the behavior so that instead of an empty allocated map, a nil will be returned. Signed-off-by: Jan Rodák <[email protected]>
b1a1078
to
43d0009
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Honny1, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
LGTM |
/lgtm |
This PR refactors:
slices.Clone
function.stringSliceWithoutValue
function.newMapFrom
.copyMapPrefferingNil
function.nil
will be returned.Follows up on: #2122