Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

utils: Optimized calculation align #229

Merged
merged 1 commit into from
Feb 13, 2022
Merged

Conversation

wllenyj
Copy link
Contributor

@wllenyj wllenyj commented Jan 22, 2022

Use bitwise operations instead of division.
The length value must be less than usize::MAX - 4, otherwise it will
panic. The result is the same as the original logic.

Signed-off-by: wllenyj wllenyj@linux.alibaba.com

@wllenyj wllenyj force-pushed the round_up branch 2 times, most recently from c155356 to cf98060 Compare January 28, 2022 09:16
@wllenyj
Copy link
Contributor Author

wllenyj commented Feb 1, 2022

@little-dude Have some comments for the pr?
Thanks.

Copy link
Owner

@little-dude little-dude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement and for adding tests :) This looks great, but could we just rename RTA into NLA for consistency? I know in the kernel it's called RTA and perhaps it was the wrong decision to diverge from that in the first place, but now that we went for NLA, I'd rather stay consistent.

Use bitwise operations instead of division.
The length value must be less than `usize::MAX - 4`, otherwise it will
panic. The result is the same as the original logic.

Signed-off-by: wllenyj <wllenyj@linux.alibaba.com>
@wllenyj
Copy link
Contributor Author

wllenyj commented Feb 12, 2022

Thanks for this improvement and for adding tests :) This looks great, but could we just rename RTA into NLA for consistency? I know in the kernel it's called RTA and perhaps it was the wrong decision to diverge from that in the first place, but now that we went for NLA, I'd rather stay consistent.

Sure, fixed.
Thank you for review.

Copy link
Owner

@little-dude little-dude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@little-dude little-dude merged commit e8728b2 into little-dude:master Feb 13, 2022
@little-dude little-dude mentioned this pull request Feb 20, 2022
10 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants