Skip to content

Commit 9cbd705

Browse files
authored
[NFC] llvm-cgdata use StringRef in exitWithError to reduce construction (#120771)
Replace `static void exitWithError(Twine Message, std::string Whence = "", std::string Hint = "")` std::string with StringRef to remove constructing Strings on every call or passing by value Fixes: #100065
1 parent af66166 commit 9cbd705

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/tools/llvm-cgdata/llvm-cgdata.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ static CGDataAction Action;
8383
static std::optional<CGDataFormat> OutputFormat;
8484
static std::vector<std::string> InputFilenames;
8585

86-
static void exitWithError(Twine Message, std::string Whence = "",
87-
std::string Hint = "") {
86+
static void exitWithError(Twine Message, StringRef Whence = "",
87+
StringRef Hint = "") {
8888
WithColor::error();
8989
if (!Whence.empty())
9090
errs() << Whence << ": ";
@@ -97,16 +97,16 @@ static void exitWithError(Twine Message, std::string Whence = "",
9797
static void exitWithError(Error E, StringRef Whence = "") {
9898
if (E.isA<CGDataError>()) {
9999
handleAllErrors(std::move(E), [&](const CGDataError &IPE) {
100-
exitWithError(IPE.message(), std::string(Whence));
100+
exitWithError(IPE.message(), Whence);
101101
});
102102
return;
103103
}
104104

105-
exitWithError(toString(std::move(E)), std::string(Whence));
105+
exitWithError(toString(std::move(E)), Whence);
106106
}
107107

108108
static void exitWithErrorCode(std::error_code EC, StringRef Whence = "") {
109-
exitWithError(EC.message(), std::string(Whence));
109+
exitWithError(EC.message(), Whence);
110110
}
111111

112112
static int convert_main(int argc, const char *argv[]) {

0 commit comments

Comments
 (0)