-
Notifications
You must be signed in to change notification settings - Fork 59
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
Remove pointer arguments where they're not needed #197
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a7e65d3
to
8ef63c5
Compare
fcbc4b0
to
0668ba9
Compare
f960cb3
to
03190bb
Compare
03190bb
to
8f09697
Compare
… than unmarshalling into the input encoding/json behaves surprisingly ([#27172](golang/go#27172), [#31924](golang/go#31924), [#26946](golang/go#26946), [#21092](golang/go#21092)) when unmarshalling into non-empty structs, and this behaviour is unexpected in this library anyway; no other methods do any user-facing unmarshalling or pointer mutation. This commit changes all of the `Update` methods that unmarshall into their inputs to no longer do that, and return a newly-allocated struct instead.
8f09697
to
7ea2919
Compare
mcncl
approved these changes
Oct 16, 2024
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.
🫗
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR: Is a bit of a doozy!
When initially creating this library, we got super trigger happy with arguments that are pointers, to the point of making most arguments pointers to structs, and most of the members of those structs pointers to scalar types.
in 99% of cases, most of these things don't need to be pointers, so i've done a refactor with the philosophy of:
nil
and its empty value - don't use pointerswhere
fooUpdate
would be the fields to update, but then the result of the update call would also be unmarshalled intofooUpdate
, rather than returned. this is an issue because encoding/json behaves surprisingly (#27172, #31924, #26946, #21092) when unmarshalling into non-empty structs, and is also just kind of a weird user interface IMO. this behaviour is replaced with something likewhere
updated
is a fullbuildkite.Foo
struct. See b116725 for more info.