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

Mutations with Default Values #4084

Closed
llchan opened this issue Nov 10, 2016 · 2 comments
Closed

Mutations with Default Values #4084

llchan opened this issue Nov 10, 2016 · 2 comments
Labels

Comments

@llchan
Copy link
Contributor

llchan commented Nov 10, 2016

The C++ mutation methods fail if the buffer has a field set to the default value and it is asked to mutate it to the same default value. This happens because SetField<T>(field, val) looks for that offset and returns false when it's missing. I think we should pass in defaultval and return val == defaultval instead when the field is unset.

As a workaround, I can add a condition on the outside to check for equality. Long term though, I think it would be best to make this change internally, both for readability and for performance.

@llchan
Copy link
Contributor Author

llchan commented Nov 10, 2016

I should add that the behavior implied with the proposed change is that if the value goes from a non-default value back to the default, it should modify the existing field rather than invalidate the operation. The assumption is that mutation is used when you want to maximize reuse, so it should invalidate as infrequently as possible.

@ghost
Copy link

ghost commented Nov 14, 2016

Agreed with both of those. Can you make a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants