Skip to content
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 more detailed comment for clearing the last nibble for odd-len NibblePath #353

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

AryanGodara
Copy link
Contributor

if (((odd + length) & 1) != 0)
    {
        ref var oldest = ref destination[spanLength];
        oldest = (byte)(oldest & 0b1111_0000);
    }

return spanLength + PreambleLength;

This portion of WriteImpl was doing an operation which was difficult to understand at first glance and needed a more detailed comment to explain.

Reference :-

If the sum of odd and length is odd, the function clears the lower nibble of the last byte in the written path.

ref var oldest = ref destination[spanLength];
gets a reference to the byte at position spanLength in the destination buffer.

oldest = (byte)(oldest & 0b1111_0000);
clears the lower nibble of this byte by performing a bitwise AND with 0b1111_0000 (which is 0xF0).

Copy link

Code Coverage

Package Line Rate Branch Rate Health
Paprika 85% 79%
Summary 85% (3940 / 4648) 79% (1248 / 1584)

Minimum allowed line rate is 75%

@Scooletz Scooletz merged commit 17e2704 into main Jun 12, 2024
2 checks passed
@Scooletz Scooletz deleted the comment-oldest-writeimpl branch June 12, 2024 13:25
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.

2 participants