Skip to content
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

Merged
merged 1 commit into from
Feb 20, 2021

Conversation

jandem
Copy link
Contributor

@jandem jandem commented Feb 14, 2021

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.

@google-cla
Copy link

google-cla bot commented Feb 14, 2021

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 @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@floitsch floitsch left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit.

Suggested change
// 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

Comment on lines 48 to 50
// 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.
Copy link
Collaborator

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:

Suggested change
// 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'.

@jandem
Copy link
Contributor Author

jandem commented Feb 14, 2021

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.

…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.
@jandem
Copy link
Contributor Author

jandem commented Feb 20, 2021

@floitsch I got the CLA sorted out and updated the patch with your suggestions. Please take another look? :)

Copy link
Collaborator

@floitsch floitsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@floitsch floitsch merged commit af900a7 into google:master Feb 20, 2021
@floitsch
Copy link
Collaborator

Thanks!

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.

None yet

2 participants