This is an archive of the discontinued LLVM Phabricator instance.

[lldb][NFCI] Avoid construction of temporary std::strings in Variable
ClosedPublic

Authored by bulbazord on Jul 10 2023, 1:42 PM.

Details

Summary

A common thing to do is to call str().c_str() to get a null-terminated
string out of an existing StringRef. Most of the time this is to be able
to use a printf-style format string. However, llvm::formatv can handle
StringRefs without the need for the additional allocation. Using that
makes more sense.

Diff Detail

Event Timeline

bulbazord created this revision.Jul 10 2023, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 1:42 PM
bulbazord requested review of this revision.Jul 10 2023, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 1:42 PM
This revision is now accepted and ready to land.Jul 10 2023, 2:07 PM