seq: Removed zero-padding of string when parsing with parse_exponent_no_decimal#6185
Merged
sylvestre merged 5 commits intouutils:mainfrom Apr 8, 2024
maxer137:main
Merged
seq: Removed zero-padding of string when parsing with parse_exponent_no_decimal#6185sylvestre merged 5 commits intouutils:mainfrom maxer137:main
sylvestre merged 5 commits intouutils:mainfrom
maxer137:main
Conversation
When exponent is greater than 0 we previously created a new string causing us to create a new string with a much larger size. This would the get passed to the BigDecimal crate which would get stuck.
I had made the mistake of not running all the tests. This is indeed needed. However, you still need to add the exponent if it's positive for 0 numbers. This way, 0 numbers (such as 0e+5) will be counted as having a width of 5. This change also removes the memory allocation needed for the previous implementation. Where the string itself would be padded with zeros on the right side. Creating large numbers this method would cause large allocations in memory. This does not seem to fix issue #6182.
|
GNU testsuite comparison: |
This adds the same fix applied to `parse_exponent_no_decimal`. This way we don't need to create large strings
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
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.
This relates to #6182, but does not close the issue.
I looked into how seq parsed the width and found that we were padding the string with zeroes based on the exponent. This would mean that numbers with large exponents would generate a string with the same number of characters.
This PR removes the generation of the string.
Instead, the num_integral_digits is calculated directly. No new strings are generated now when parsing an exponent without decimals.