The amount of roundtrips between StringRefs, ConstStrings and std::strings is
getting a bit out of hand, this patch avoid the unnecessary roundtrips.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lldb/source/API/SBTarget.cpp | ||
---|---|---|
1589–1590 | Aside (since the old code did this too): Generally code should prefer = initialization over () initialization - because the former can't invoke explicit conversions, so is easier to read because it limits the possible conversion to simpler/safer ones (for instance, with unique ptrs "std::unique_ptr<int> p = x();" tells me x() returns a unique_ptr or equivalent, but std::unique_ptr<int> p(x()); could be that x() returns a raw pointer and then I have to wonder if it meant to transfer ownership or not - but I don't have to wonder that in the first example because the type system checks that for me). Admittedly StringRef has no explicit ctors - but it's a good general style to use imho (would be happy to include this in the LLVM style guide if this seems contentious in any way & is worth some discussion/formalization - but I think it's just generally good C++ practice & hopefully can be accepted as such) | |
lldb/source/Target/PathMappingList.cpp | ||
35 | out of date comment - maybe this comment isn't pulling its weight? The content seems fairly simple/probably self explanatory? |
@wallace rebased
But I guess you should apply this patch firstly?
https://reviews.llvm.org/D112439
This breaks our build: https://green.lab.llvm.org/green/job/lldb-cmake/37529/console
Can you take a look? If the fix is not obvious, please revert for now.
Aside (since the old code did this too): Generally code should prefer = initialization over () initialization - because the former can't invoke explicit conversions, so is easier to read because it limits the possible conversion to simpler/safer ones (for instance, with unique ptrs "std::unique_ptr<int> p = x();" tells me x() returns a unique_ptr or equivalent, but std::unique_ptr<int> p(x()); could be that x() returns a raw pointer and then I have to wonder if it meant to transfer ownership or not - but I don't have to wonder that in the first example because the type system checks that for me).
Admittedly StringRef has no explicit ctors - but it's a good general style to use imho (would be happy to include this in the LLVM style guide if this seems contentious in any way & is worth some discussion/formalization - but I think it's just generally good C++ practice & hopefully can be accepted as such)