Open FintasticMan opened 1 year ago
Build size and comparison to main: | Section | Size | Difference |
---|---|---|---|
text | 406604B | -32B | |
data | 940B | 0B | |
bss | 53568B | 0B |
I think the terminator will always cause confusion as long as the truncation needs to happen outside of NotificationManager. I think NotificationManager should accept any std::string and truncate it internally.
I think that would be a shame personally, because I think it should be possible to make it clear what is what through good naming and consistency. For example by using len to indicate number of chars excluding null terminator, and size being number of bytes total.
Anyway, the reason I would rather not use std::string is because it is always allocated on the heap, which seems wasteful if we're just putting it onto the stack again right after.
Would string_view be better?
The message array in the Notification struct has a size of MaximumMessageSize + 1, for a trailing null terminator if the message is MaximumMessageSize chars. This extra char isn't used for notifications coming from bluetooth, meaning that notifications are truncated 1 character earlier if they are too long. This change is minor and just means that notifications can be 1 character longer.