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

Replace base10 users of StringUtil::atoull with absl::SimpleAtoi #6697

Merged
merged 6 commits into from
Apr 25, 2019

Conversation

dnoe
Copy link
Contributor

@dnoe dnoe commented Apr 24, 2019

Description: absl::SimpleAtoi takes absl::string_view argument and can easily replace all of the calls to StringUtil::atoull that are using Base 10 conversion. This eliminates a significant number of places where a std::string needed to be constructed from string_view to obtain a C string for StringUtil:atoull.

Risk Level: Low
Testing: bazel test //test/...
Docs Changes: N/A
Release Notes: N/A
Part of: Issue #6580

Signed-off-by: Dan Noé dpn@google.com

absl::SimpleAtoi takes absl::string_view argument and can easily replace
all of the calls to StringUtil::atoull that are using Base 10
conversion. This eliminates a significant number of places where a
std::string needed to be constructed from string_view to obtain a
C string for StringUtil:atoull.

Signed-off-by: Dan Noé <dpn@google.com>
Signed-off-by: Dan Noé <dpn@google.com>
@dnoe dnoe requested a review from snowp as a code owner April 24, 2019 18:14
Signed-off-by: Dan Noé <dpn@google.com>
@lizan lizan self-assigned this Apr 24, 2019
Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

LGTM, just questions.

@@ -154,6 +154,9 @@ class StringUtil {

/**
* Convert a string to an unsigned long, checking for error.
*
* Consider absl::SimpleAtoi instead if using base 10.
*
* @param return true if successful, false otherwise.
*/
static bool atoull(const char* str, uint64_t& out, int base = 10);
Copy link
Member

Choose a reason for hiding this comment

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

Where is the remaining use cases of this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are all hex conversions. I haven't dug around for the best option yet to replace them, but I plan to do that next as part of ongoing #6580 work.

I am also planning to eliminate StringUtil::atoll since every existing use case of it is base 10 and can just be replaced with absl::SimpleAtoi.

Signed-off-by: Dan Noé <dpn@google.com>
lizan
lizan previously approved these changes Apr 24, 2019
@lizan
Copy link
Member

lizan commented Apr 25, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)
🔨 rebuilding ci/circleci: asan (failed build)

🐱

Caused by: a #6697 (comment) was created by @lizan.

see: more, trace.

@dnoe
Copy link
Contributor Author

dnoe commented Apr 25, 2019

asan looks like a real issue, fixing.

This one needs an explicit string construction.

Signed-off-by: Dan Noé <dpn@google.com>
@dnoe
Copy link
Contributor Author

dnoe commented Apr 25, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #6697 (comment) was created by @dnoe.

see: more, trace.

@lizan lizan merged commit 71552f0 into envoyproxy:master Apr 25, 2019
@@ -57,10 +57,9 @@ void Common::chargeStat(const Upstream::ClusterInfo& cluster, const std::string&
grpc_status->value().getStringView()))
.inc();
uint64_t grpc_status_code;
const std::string grpc_status_string(grpc_status->value().getStringView());
// TODO(dnoe): Migrate to pure string_view (#6580)
Copy link
Member

Choose a reason for hiding this comment

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

@dnoe I think this can be removed now? Can you merge into one of your follow ups?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

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.

3 participants