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.
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.
Why can't
toString()
just be called on data?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.
Yeah -- this is the trick :)
In envoyproxy/envoy#3629 @htuch challenged me why we need another interface function (toString()) which is somewhat overlapping with serialize(). So I noted that removing it from the abstract interface and just having that function on BufferOwned::Impl worked (that's the way it is checked in now).
However it doesn't work to just say buffer_interface_var->toString(), even though it worked to call TestUtility::bufferToString(buffer_interface_var). The reason that worked is that OwnedImpl has an implicit constructor from const BufferInstance&, so the compiler automatically finds that.
So in envoyproxy/envoy#3736 I worked around that by adding the new interface in Buffer::Instance, but in this PR, in a different repo, I don't have that. So I help the compiler out by explicitly constructing the Buffer::OwnedImpl from the Buffer::Instance before referencing.
I could also go back to envoyproxy/envoy#3736 and remove the Buffer::Interface::toString(), and instead rely on explicit construction of an OwnedImpl in order to access its toString(). I think that happens about 10 of the 53 times this gets called in that repo. I'm fine either way.
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.
We can also just force merge this even though it doesn't pass tests, and then update the SHA here once the other thing merges. That's probably cleaner?
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.
That's fine with me too if it's OK to wind up with Buffer::Instance::toString() permanently.
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.
Sorry I don't follow. It's on the interface in your current PR. At that point, can't you just do
data.toString()
?