Skip to content

Commit 18058f2

Browse files
committed
[llvm][GraphWriter] Resize std::string, instead of reassigning to substr (NFC)
* Don't call substr which creates a new string instance * Only call string method if string length is larger than 140 Closes #90324
1 parent 90bd723 commit 18058f2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Support/GraphWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
115115

116116
// Windows can't always handle long paths, so limit the length of the name.
117117
std::string N = Name.str();
118-
N = N.substr(0, std::min<std::size_t>(N.size(), 140));
118+
if (N.size() > 140)
119+
N.resize(140);
119120

120121
// Replace illegal characters in graph Filename with '_' if needed
121122
std::string CleansedName = replaceIllegalFilenameChars(N, '_');

0 commit comments

Comments
 (0)