Skip to content

Conversation

@KishorMore-2005
Copy link
Contributor

Removes redundant bit shift and arithmetic operations (<< 0, >> 0, + 0)
from EndianUtils methods. These operations have no effect on values and
were making the code unnecessarily verbose. No functional changes.

@garydgregory
Copy link
Member

-1 and closing: I think this class was originally authored in this style for readability, which is subjective I'll grant.

@sebbASF
Copy link
Contributor

sebbASF commented Feb 8, 2026

Agreed: having the zeros in place shows that they are part of the sequence of values, rather than a special case.

This is obvious here:

return ((data[offset + 0] & 0xff) << 0) +
((data[offset + 1] & 0xff) << 8) +
((data[offset + 2] & 0xff) << 16) +
((data[offset + 3] & 0xff) << 24);

Less so here:

return ((value1 & 0xff) << 0) + ((value2 & 0xff) << 8) + ((value3 & 0xff) << 16) + ((value4 & 0xff) << 24);

That instance seems to have lots its original layout:

return (int)( ( ( value1 & 0xff ) << 0 ) +
( ( value2 & 0xff ) << 8 ) +
( ( value3 & 0xff ) << 16 ) +
( ( value4 & 0xff ) << 24 ) );

It might be worth resorting to the original layout throughout, but that is a separate issue.

@KishorMore-2005 KishorMore-2005 deleted the branch2 branch February 8, 2026 14:39
@KishorMore-2005
Copy link
Contributor Author

okay , Thank you for explanation!

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.

3 participants