<charconv>
: _Divide
can trim _Big_integer_flt
more efficiently
#2623
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.
We have a comment explaining how
_Big_integer_flt
accesses only[0, _Myused)
and tolerates all other elements being garbage:STL/stl/inc/charconv
Lines 366 to 369 in 2787718
Now, look at the following code at the end of
_Divide
:STL/stl/inc/charconv
Lines 1034 to 1045 in 2787718
I claim that the first loop is unnecessary. It's zeroing out elements in the range
[_Max_numerator_element_index + 1, original _Myused)
. Then, the following code updates_Myused
to at most_Max_numerator_element_index + 1
. (Possibly less, if we discover that there are more zero elements at the end of this range.)According to
_Big_integer_flt
's invariants, the_Myused
update already makes the contents of the range[_Max_numerator_element_index + 1, original _Myused)
irrelevant - thus we don't need to spend extra time zeroing them out.Noticed while working on #2366.