Skip to content

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

Merged
lizan merged 6 commits intoenvoyproxy:masterfrom
dnoe:simple-atoi
Apr 25, 2019
Merged

Replace base10 users of StringUtil::atoull with absl::SimpleAtoi#6697
lizan merged 6 commits intoenvoyproxy:masterfrom
dnoe:simple-atoi

Conversation

@dnoe
Copy link
Copy Markdown
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

dnoe added 2 commits April 24, 2019 14:03
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
Copy Markdown
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.

*
* @param return true if successful, false otherwise.
*/
static bool atoull(const char* str, uint64_t& out, int base = 10);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

lizan commented Apr 25, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 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
Copy Markdown
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
Copy Markdown
Contributor Author

dnoe commented Apr 25, 2019

/retest

@repokitteh-read-only
Copy link
Copy Markdown

🔨 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
.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
Copy Markdown
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
Copy Markdown
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