Skip to content

clean up unnecessary std::string() in Envoy #11318

Open

Description

@alyssawilk

see discussion in #11287 for some examples

Activity

  1. added
    beginner
    on May 26, 2020
  2. yashwant121 commented on Jun 3, 2020

    @yashwant121

    Hi @alyssawilk, I would like to take this issue.

  3. alyssawilk commented on Jun 3, 2020

    @alyssawilk
    ContributorAuthor

    Thanks! Tossing it your way :-)

  4. PranshuSrivastava commented on May 14, 2021

    @PranshuSrivastava

    Hey, @alyssawilk I would like to take this issue.

  5. PranshuSrivastava commented on May 21, 2021

    @PranshuSrivastava

    Hey, @alyssawilk I am not able to understand which std:: strings are not required. Could you tell me how do I decide which ones to remove and which ones to keep?

  6. alyssawilk commented on May 24, 2021

    @alyssawilk
    ContributorAuthor

    grep -r std::string( source/* gets you potential call sites, but you'd have to figure out which results are unnecessary

  7. akonradi commented on Jun 16, 2021

    @akonradi
    Contributor

    Expounding on the above, std::string(x) creates a new string object by copying the contents of x. That's great and necessary if the string needs to outlive x, but if not then the copy is just wasting CPU time. If you can replace std::string(x) with just x and all the tests still pass, then that conversion probably wasn't required! You might come across a few places where a string_view is converted to call a method that takes a const std::string&, but in that case we should make the method take a string_view instead since it's the moral equivalent and more flexible.

  8. ShubhamPalriwala commented on Jul 14, 2021

    @ShubhamPalriwala

    Hey @alyssawilk, I have understood the issue and would like to work on this! Just wanted to ask, will one heavy commit be fine?

  9. alyssawilk commented on Jul 14, 2021

    @alyssawilk
    ContributorAuthor

    I'm not sure how many there are. If there are 20-30 cases sure, if it's more like 200 then splitting it up into a few PRs would be super helpful :-)

  10. ShubhamPalriwala commented on Jul 14, 2021

    @ShubhamPalriwala

    There are 1352 instances of this so I have to check each one of them. 😩
    Should I make different PRs for each directory then?

  11. alyssawilk commented on Jul 14, 2021

    @alyssawilk
    ContributorAuthor

    I'd group somewhat arbitrarily to try to manage PR sizes - if there's a root directory with ~50 you can do the whole thing, where sometimes you might need to limit to one type of extension depending on how many changes there are. Maybe kick one off and see how it goes, and iterate from there?

  12. ShubhamPalriwala commented on Jul 15, 2021

    @ShubhamPalriwala

    Alright! Quick question, is there any way to speed up the tests? I've fired up a VM with 4 vCPUs and 32 gigs of RAM for this but the tests still take more than hours to get done.

    Help here would really really be great!

  13. alyssawilk commented on Jul 15, 2021

    @alyssawilk
    ContributorAuthor

    yeah, 4 CPUs is going to take a while. :-(
    I find that on slow machines kicking off an overnight build, then doing incremental builds the next day helps. Also if you're mainly checking compile/asan you can just test //test/path/to/code/changed rather than the whole suite, then rely on CI for the full pass.

  14. annanya-mathur commented on Aug 28, 2021

    @annanya-mathur

    I would like to take this issue

  15. TTashev commented on Jun 19, 2022

    @TTashev

    Hello, anybody still working on this, I would like to participate.

  16. alyssawilk commented on Jun 21, 2022

    @alyssawilk
    ContributorAuthor

    Feel free to send out PRs!

  17. Akshayshahi900 commented on Jun 30, 2026

    @Akshayshahi900

    Hi, I'd like to work on this. I'll grep the codebase for remaining unnecessary std::string() usages and submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

beginnerhelp wantedtech debt

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions