Skip to content

replace std:string to absl::string - #19032

Merged
rojkov merged 1 commit into
envoyproxy:mainfrom
ME-ON1:absl-const
Nov 19, 2021
Merged

rojkov merged 1 commit into
envoyproxy:mainfrom
ME-ON1:absl-const

Conversation

@ME-ON1

@ME-ON1 ME-ON1 commented Nov 17, 2021 •

Copy link
Copy Markdown
Contributor

Signed-off-by: Tarun Sharma [email protected]

Commit Message: replace std:string to absl::string
Additional Description: #11318
Risk Level: N/A
Testing: N/A
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:] N/A
[Optional Fixes #Issue] N/A
[Optional Fixes commit #PR or SHA] N/A
[Optional Deprecated:] N/A
[Optional API Considerations:] N/A

@rojkov

rojkov commented Nov 18, 2021

Copy link
Copy Markdown
Member

/assign-from @envoyproxy/first-pass-reviewers

@repokitteh-read-only

Copy link
Copy Markdown

@envoyproxy/first-pass-reviewers assignee is @dmitri-d

🐱

Caused by: a #19032 (comment) was created by @rojkov.

see: more, trace.

@rojkov

rojkov commented Nov 18, 2021

Copy link
Copy Markdown
Member

/assign-from @envoyproxy/first-pass-reviewers

@repokitteh-read-only

Copy link
Copy Markdown

@envoyproxy/first-pass-reviewers assignee is @jmarantz

🐱

Caused by: a #19032 (comment) was created by @rojkov.

see: more, trace.

@rojkov rojkov assigned rojkov and unassigned jmarantz Nov 18, 2021

@rojkov rojkov left a comment

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.

Thank you for the cleanup! Added a suggestion.

} // namespace

std::string Base64::decode(const std::string& input) {
std::string Base64::decode(absl::string_view input) {

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.

I think preserving const-ness won't do much harm, but will help to detect erroneous mutation of input inside the function.

Suggested change
std::string Base64::decode(absl::string_view input) {
std::string Base64::decode(const absl::string_view input) {

Here and in the other functions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't feel that strongly about this, but we don't tend to do this from what I've seen in the Envoy codebase. Also why would we do this for absl::string_view and not for (say) int on input params?

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.

top level const shouldn't be in declaration because it doesn't affect method signature (https://clang.llvm.org/extra/clang-tidy/checks/readability-avoid-const-params-in-decls.html)
but in implementation it is encouraged.

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.

Thank you @lizan! I stand corrected )

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.

thank y'all got a great insight!!

@jmarantz jmarantz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

const input tweaks notwithstanding this lgtm.

Also IMO this is not deep enough to require senior maintainer attention but I'll ask for it anyway to adjudicate on const input params :)

/assign-from @envoyproxy/senior-maintainers

While we're waiting for that can you fill out the fields in the PR description, noting "N/A" for fields you feel are not applicable?

Thank you!

@repokitteh-read-only

Copy link
Copy Markdown

@envoyproxy/senior-maintainers assignee is @zuercher

🐱

Caused by: a #19032 (review) was submitted by @jmarantz.

see: more, trace.

@zuercher zuercher left a comment

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.

Thanks! lgtm

@jmarantz I'll leave the merge to you when you're happy with the description, etc.

@rojkov rojkov left a comment

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.

LGTM!

} // namespace

std::string Base64::decode(const std::string& input) {
std::string Base64::decode(absl::string_view input) {

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.

Thank you @lizan! I stand corrected )

@rojkov
rojkov merged commit 8538792 into envoyproxy:main Nov 19, 2021
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.

6 participants