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

Add restrict qualifier to serializer output buffer #2148

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eboasson
Copy link
Contributor

... 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 as restrict. 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 a dds_ostream_t to a pointer of the (new type) restrict_ostream_t at the entry points of the serializer. All other casts between the ostream 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 single restrict keyword that this PR adds and keep all the other changes. (Perhaps with the restrict_ostream_t renamed, too 🙂)

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.

1 participant