Skip to content
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

V2: Change return type of merge functions #867

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

timostamm
Copy link
Member

The current function signatures of mergeFromBinary, mergeFromJson, and mergeFromJsonString ambiguous: It is not obvious whether the function mutates the message given as an argument, or whether it clones the message first, and returns the mutated clone.

To remove this ambiguity, this PR changes the return types to void, making it obvious that the functions mutate the argument.

To be honest, it seems that it would be most idiomatic to return a copy. But in some use cases, that can be a prohibitively expensive operation. So mutating the argument seems to be the best choice. In case we're wrong about that, we can still add variants that return a clone, for example as mergeBinary.

@timostamm timostamm merged commit 01045de into v2 Jun 3, 2024
7 checks passed
@timostamm timostamm deleted the tstamm/return-void-in-merge branch June 3, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants