-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call StrtodTrimmed/StrtofTrimmed from StringToDoubleConverter::StringToIeee. #154
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -729,11 +729,17 @@ double StringToDoubleConverter::StringToIeee( | |||
DOUBLE_CONVERSION_ASSERT(buffer_pos < kBufferSize); | |||
buffer[buffer_pos] = '\0'; | |||
|
|||
// Code above ensures there are no leading zeros and the buffer has less than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit.
// Code above ensures there are no leading zeros and the buffer has less than | |
// Code above ensures there are no leading zeros and the buffer has fewer than |
double-conversion/strtod.h
Outdated
// For special use cases, the heart of the Strtof() function is also available | ||
// separately, it assumes that 'trimmed' is as produced by TrimAndCut(), i.e. | ||
// no leading or trailing zeros, also no lone zero, and not 'too many' digits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of the wording, but it is a copy of StrtodTrimmed
.
Probably would write something like the following now:
// For special use cases, the heart of the Strtof() function is also available | |
// separately, it assumes that 'trimmed' is as produced by TrimAndCut(), i.e. | |
// no leading or trailing zeros, also no lone zero, and not 'too many' digits. | |
// Same as Strtof, but assumes that 'trimmed' is already trimmed, as if run through TrimAndCut. | |
// That is, 'trimmed' must have no leading or trailing zeros, must not be a lone zero, and must not have | |
// 'too many' digits. |
Feel free to ignore the suggestion.
If you accept it, please also change 'StrtodTrimmed'.
Thanks for the fast review. I'm happy to address the suggestions, but will need to figure out the CLA thing first. I'll try to get that sorted out. |
bd53972
to
dd3d572
Compare
…ToIeee. We know the buffer contains no leading zeros and less than kMaxSignificantDecimalDigits, so we only need to trim trailing zeros and can then call Strto*Trimmed, which is quite a bit faster.
dd3d572
to
e9b8660
Compare
@floitsch I got the CLA sorted out and updated the patch with your suggestions. Please take another look? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks! |
We know the buffer contains no leading zeros and less than kMaxSignificantDecimalDigits, so we only need to trim trailing zeros and can then call Strto*Trimmed, which is quite a bit faster.