[llvm] 18058f2 - [llvm][GraphWriter] Resize std::string, instead of reassigning to substr (NFC)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 14:21:45 PDT 2024
Author: Youngsuk Kim
Date: 2024-05-02T16:20:46-05:00
New Revision: 18058f2a32854d2d257cff47b28479b2ff425496
URL: https://github.com/llvm/llvm-project/commit/18058f2a32854d2d257cff47b28479b2ff425496
DIFF: https://github.com/llvm/llvm-project/commit/18058f2a32854d2d257cff47b28479b2ff425496.diff
LOG: [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
Added:
Modified:
llvm/lib/Support/GraphWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp
index 0c7aacb2fe21a7..5583ca18ab20f1 100644
--- a/llvm/lib/Support/GraphWriter.cpp
+++ b/llvm/lib/Support/GraphWriter.cpp
@@ -115,7 +115,8 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
// Windows can't always handle long paths, so limit the length of the name.
std::string N = Name.str();
- N = N.substr(0, std::min<std::size_t>(N.size(), 140));
+ if (N.size() > 140)
+ N.resize(140);
// Replace illegal characters in graph Filename with '_' if needed
std::string CleansedName = replaceIllegalFilenameChars(N, '_');
More information about the llvm-commits
mailing list