perf: add a stack-allocated to_base_be#490
Merged
prestwich merged 1 commit intorecmo:mainfrom Jul 21, 2025
Merged
Conversation
CodSpeed Performance ReportMerging #490 will improve performances by 68.04%Comparing Summary
Benchmarks breakdown
|
4dadf5a to
25c818f
Compare
3 tasks
f301658 to
6d90132
Compare
DaniPopes
commented
Jul 18, 2025
| /// Panics if the base is less than 2. | ||
| #[inline] | ||
| #[track_caller] | ||
| pub fn to_base_be_2(&self, base: u64) -> impl Iterator<Item = u64> { |
Contributor
Author
There was a problem hiding this comment.
should this be public?
Collaborator
There was a problem hiding this comment.
I'm mostly fine with it being public, but can we add some more docs?
- what exactly would be breaking (an example would be great
- when it is recommended to use
_2vsto_base_be - a reference to
_2in the docs forto_base_bedescribing when it should be used
prestwich
approved these changes
Jul 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
to_base_be_2, which allocates the result ofto_base_leon the stack instead of the heap, and use it infmt.This is faster than
to_base_be(#488), which does 2 divisions per iteration instead of 1. However it only works for the biggest power of the base, so it can't replaceto_base_beentirely as it would be a breaking change.Based on #488.