Skip to content

Optimize to_bytes() using table lookup#127

Open
fereidani wants to merge 2 commits intocontain-rs:masterfrom
fereidani:master
Open

Optimize to_bytes() using table lookup#127
fereidani wants to merge 2 commits intocontain-rs:masterfrom
fereidani:master

Conversation

@fereidani
Copy link

Hey,
Great project! I just made these changes to optimize to_bytes(), you can use the added benchmark to check the performance.
I only tested this on my AMD x64 6650u.
It would be a good idea to test it on other platforms before merging.
I also tested directly using reverse_bits like:

result.push(i.reverse_bits());

and it performed worst than lookup table solution.

@pczarn
Copy link
Contributor

pczarn commented Feb 5, 2026

Thanks! Will benchmark and merge

@pczarn
Copy link
Contributor

pczarn commented Feb 5, 2026

My benches show an improvement from 37 us to 25 us

Copy link
Contributor

@pczarn pczarn left a comment

Choose a reason for hiding this comment

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

Good

@pczarn
Copy link
Contributor

pczarn commented Feb 5, 2026

How do I run these CI checks? Could you re-push or re-open?

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