-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 macro to convert bits to bytes (CSE of rounding idiom) #2378
base: master
Are you sure you want to change the base?
Conversation
0c04284
to
259378d
Compare
I have to think about this, not sure if I like using macros. I would say |
Well, to me the |
259378d
to
2d373b6
Compare
93031a1
to
ed794ec
Compare
2d373b6
to
8b43761
Compare
I lean to defining somehow a function or macro. Not everyone immediately recognizes the +7 and /8 idiom, even though it's common, and I lean to clearer. I don't really like NUM_BYTES and would prefer BITS_TO_BYTES but that's not important. I don't think any compiler is going to optimize /8 but not >>3. |
I want to (and often quickly have to) look at code blocks and grasp what is going on, same as @obones. Difference is that plain instructions don't bother me much but macros are always suspect and without documentation hints macros are obfuscating more than they help (me at least). If only we could have inlined functions across compilations units... |
We can have inline functions in headers, but I am not sure it fits with the build environment rules. I don't really see macros and functions as all that different, and it seems easy to have comment explaining the macro. But really the top-level point is to make progress either merging or rejecting this; we have too many things just long-term open. |
So should we merge or reject this? |
I'm still not in favor of using more macros. Typical decoders currently don't use any macros. E.g. to me in complex code it's easier to read the block of operations here Lines 43 to 46 in 2d63f30
then having another layer with a macro call in there Lines 43 to 46 in 8b43761
But if this is seen as a useful simplification then I won't argue. |
As I have already voiced it earlier, I find the +7/8 code really hard to understand for a newcomer, hence my suggestion to use a macro. |
This fixes a warning about question mark operator precedence as discussed here: #2360