Type improvements new#98
Open
hmueller01 wants to merge 3 commits into
Open
Conversation
|
Memory usage change @ f5fc060
Click for full report table
Click for full report CSV |
TD-er
reviewed
Jul 12, 2026
| const uint16_t topicLen = (_buffer[hdrLen + 1] << 8) + _buffer[hdrLen + 2]; // topic length in bytes | ||
| char* const topic = (char*)(_buffer + hdrLen + 3 - 1); // set the topic in the LSB of the topic lenght, as we move it there | ||
| const uint16_t payloadOffset = hdrLen + 3 + topicLen; // payload starts after header and topic (if there is no packet identifier) | ||
| const size_t payloadLen = length - payloadOffset; // this might change by 2 if we have a QoS 1 or 2 message |
Collaborator
There was a problem hiding this comment.
Only remark here is that the comment is a bit odd. I had to re-read it a few times before it dawned on me what was meant here, though I still don't know why it would apply to this line of code as it is about the previous line, right?
TD-er
reviewed
Jul 12, 2026
| char* const topic = (char*)(_buffer + hdrLen + 3 - 1); // set the topic in the LSB of the topic lenght, as we move it there | ||
| const uint16_t payloadOffset = hdrLen + 3 + topicLen; // payload starts after header and topic (if there is no packet identifier) | ||
| const size_t payloadLen = length - payloadOffset; // this might change by 2 if we have a QoS 1 or 2 message | ||
| uint8_t* const payload = _buffer + payloadOffset; |
Collaborator
There was a problem hiding this comment.
I always have to think really deep about this order of const declaration, as it is about the content being const vs. the pointer address being const. (which is what is done here)
Like const uint8_t* vs uint8_t* const.
And a real beauty when using const uint8_t* const...
|
Memory usage change @ 6832ee3
Click for full report table
Click for full report CSV |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
added type improvements as suggested in #91 by @MarcAntoineCRUE