Use bitfield instead of bools in Response #5556
Open
+267
−278
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.
Closes #3862.
Factoring the
bool
members ofResponse
into a bitfield, the size ofResponse
is now 96 bytes (down from 104).I gave
Sense
the same treatment, however this has no effects onResponse
due to padding. I've decided not to pursuePointerState
, as it is quite large (many members that are sized and aligned to multiples of 8 bytes), so I don't expect any noticeable benefit from making handful ofbool
s slightly leaner.In any case, the changes to
Sense
are already quite a bit more intrusive than those toResponse
.The previous implementation overloaded the names of the attributes
click
anddrag
with similarly named methods that constructSense
with the corresponding flag set. Now, that the attributes can no longer be accessed directly, I had to introduce methods with new names (senses_click()
,senses_drag()
andis_focusable()
). I don't think this is the cleanest solution: the old methods are essentially redundant now that the named constants likeSense::CLICK
exist. I did however not want to needlessly break backwards compatibility.I am happy to revert it (or go further 🙂) if there are concerns.