[llvm] 176ab5e - [llvm-lto2] Simplify SymbolResolutions loop and avoid expensive std::string copy. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 15:50:50 PDT 2024


Author: Fangrui Song
Date: 2024-04-26T15:50:44-07:00
New Revision: 176ab5e9de540f4abcae4a232541f8493de11fc6

URL: https://github.com/llvm/llvm-project/commit/176ab5e9de540f4abcae4a232541f8493de11fc6
DIFF: https://github.com/llvm/llvm-project/commit/176ab5e9de540f4abcae4a232541f8493de11fc6.diff

LOG: [llvm-lto2] Simplify SymbolResolutions loop and avoid expensive std::string copy. NFC

Added: 
    

Modified: 
    llvm/tools/llvm-lto2/llvm-lto2.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index faed9ff9939bd5..5dd961a603c9e8 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -251,10 +251,9 @@ static int run(int argc, char **argv) {
   // resolutions and apply them in the order observed.
   std::map<std::pair<std::string, std::string>, std::list<SymbolResolution>>
       CommandLineResolutions;
-  for (std::string R : SymbolResolutions) {
-    StringRef Rest = R;
-    StringRef FileName, SymbolName;
-    std::tie(FileName, Rest) = Rest.split(',');
+  for (StringRef R : SymbolResolutions) {
+    StringRef Rest, FileName, SymbolName;
+    std::tie(FileName, Rest) = R.split(',');
     if (Rest.empty()) {
       llvm::errs() << "invalid resolution: " << R << '\n';
       return 1;


        


More information about the llvm-commits mailing list