This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFC] avoid unnecessary roundtrips between different string types
ClosedPublic

Authored by xujuntwt95329 on Oct 29 2021, 9:00 PM.

Details

Summary

The amount of roundtrips between StringRefs, ConstStrings and std::strings is
getting a bit out of hand, this patch avoid the unnecessary roundtrips.

Diff Detail

Event Timeline

xujuntwt95329 requested review of this revision.Oct 29 2021, 9:00 PM
xujuntwt95329 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2021, 9:00 PM
wallace accepted this revision.Oct 29 2021, 10:21 PM

thanks!

This revision is now accepted and ready to land.Oct 29 2021, 10:21 PM
dblaikie added inline comments.
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?

address dblaikie's comments

xujuntwt95329 marked 2 inline comments as done.Oct 29 2021, 11:17 PM

@dblaikie Thanks for your detailed comments, I've uploaded the new patch-set

@xujuntwt95329 do you have push permissions or do you need help to land this diff?

@xujuntwt95329 do you have push permissions or do you need help to land this diff?

I don't have push permissions, could you please help me to land this?

Thanks a lot!

aprantl accepted this revision.Nov 1 2021, 3:58 PM

Thank you!

This comment was removed by wallace.

@wallace rebased

But I guess you should apply this patch firstly?
https://reviews.llvm.org/D112439

This revision was landed with ongoing or failed builds.Nov 1 2021, 10:15 PM
This revision was automatically updated to reflect the committed changes.

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.