Thanks to visit codestin.com
Credit goes to github.com

Skip to content

seq: Removed zero-padding of string when parsing with parse_exponent_no_decimal#6185

Merged
sylvestre merged 5 commits intouutils:mainfrom
maxer137:main
Apr 8, 2024
Merged

seq: Removed zero-padding of string when parsing with parse_exponent_no_decimal#6185
sylvestre merged 5 commits intouutils:mainfrom
maxer137:main

Conversation

@maxer137
Copy link
Contributor

@maxer137 maxer137 commented Apr 3, 2024

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.

maxer137 added 3 commits April 3, 2024 16:07
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.
@github-actions
Copy link

github-actions bot commented Apr 3, 2024

GNU testsuite comparison:

Skipping an intermittent issue tests/rm/rm1 (passes in this run but fails in the 'main' branch)

This adds the same fix applied to `parse_exponent_no_decimal`.
This way we don't need to create large strings
@github-actions
Copy link

github-actions bot commented Apr 5, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)

@github-actions
Copy link

github-actions bot commented Apr 6, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)

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

Comments