Add restrict qualifier to serializer output buffer #2148
+279
−255
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.
... and two unrelated and very minor details.
Thinking about the use of
restrict
while cleaning it up in #2145, it seemed sensible to also mark the output buffer of the serializer asrestrict
. Clearly things will go horribly wrong if it aliases any of the inputs of the serializer, it is one of those essentially untyped buffers and so clearly a case where qualifying it may avoid some reloads of things after storing data in it. I don't really think it is very likely, but ok.Those restrictions don't apply to the caller's use of the buffer before or after. So
dds_ostream_t
shouldn't be changed ... This solves this by casting a pointer to adds_ostream_t
to a pointer of the (new type)restrict_ostream_t
at the entry points of the serializer. All other casts between theostream
variants (and there were quite a few) have been eliminated.Just the elimination of the multitude of casts was worth the effort. If objections are raised to the use of the
restrict
qualifier for this buffer, then it makes sense to drop just that singlerestrict
keyword that this PR adds and keep all the other changes. (Perhaps with therestrict_ostream_t
renamed, too 🙂)