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

opt: use the std math/bits routine to count the bit length #437

Merged
merged 1 commit into from
Feb 5, 2023

Conversation

0-haha
Copy link
Contributor

@0-haha 0-haha commented Feb 1, 2023

1. Are you opening this pull request for bug-fixes, optimizations or new feature?

optimizations

2. Please describe how these code changes achieve your intention.

bits.Len() is optimized by the compiler as an intrinsic function, which uses an inline BSRQ instruction. This is significantly faster than using the for loop.

See the corresponding assembly code https://godbolt.org/z/rTebv3q7c

3. Please link to the relevant issues (if any).

no

4. Which documentation changes (if any) need to be made/updated because of this PR?

no

4. Checklist

  • I have squashed all insignificant commits.
  • I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • I have written unit tests and verified that all tests passes (if needed).
  • I have documented feature info on the README (only when this PR is adding a new feature).
  • (optional) I am willing to help maintain this change if there are issues with it later.

@codecov
Copy link

codecov bot commented Feb 1, 2023

Codecov Report

Base: 76.46% // Head: 76.46% // No change to project coverage 👍

Coverage data is based on head (87d6195) compared to base (0f41b37).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #437   +/-   ##
=======================================
  Coverage   76.46%   76.46%           
=======================================
  Files          15       15           
  Lines        1500     1500           
=======================================
  Hits         1147     1147           
  Misses        271      271           
  Partials       82       82           
Flag Coverage Δ
unittests 76.46% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@panjf2000 panjf2000 merged commit fbeb65d into panjf2000:dev Feb 5, 2023
@panjf2000
Copy link
Owner

Thanks~

@0-haha 0-haha deleted the dev-opt branch February 5, 2023 15:50
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