[llvm] fixed #95641 pointless string copy (PR #127325)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 03:52:06 PST 2025


https://github.com/sommersun updated https://github.com/llvm/llvm-project/pull/127325

>From f14375b9953506ca3eaa6a73474f2a7cf5242210 Mon Sep 17 00:00:00 2001
From: sxx <948074686 at qq.com>
Date: Sat, 15 Feb 2025 21:56:28 +0800
Subject: [PATCH] #95641 pointless string copy

---
 llvm/include/llvm/TableGen/Record.h | 4 +---
 llvm/lib/TableGen/Main.cpp          | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h
index e04ed34823148..e7fe9ab55267b 100644
--- a/llvm/include/llvm/TableGen/Record.h
+++ b/llvm/include/llvm/TableGen/Record.h
@@ -1966,9 +1966,7 @@ class RecordKeeper {
     return It == ExtraGlobals.end() ? nullptr : It->second;
   }
 
-  void saveInputFilename(std::string Filename) {
-    InputFilename = Filename;
-  }
+  void saveInputFilename(std::string &&Filename) { InputFilename = Filename; }
 
   void addClass(std::unique_ptr<Record> R) {
     bool Ins =
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index 35600bf2f1f86..81b2e81dc6064 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -113,7 +113,7 @@ int llvm::TableGenMain(const char *argv0,
     return reportError(argv0, "Could not open input file '" + InputFilename +
                                   "': " + EC.message() + "\n");
 
-  Records.saveInputFilename(InputFilename);
+  Records.saveInputFilename(std::move(InputFilename));
 
   // Tell SrcMgr about this buffer, which is what TGParser will pick up.
   SrcMgr.AddNewSourceBuffer(std::move(*FileOrErr), SMLoc());



More information about the llvm-commits mailing list