[llvm] [NFC][TableGen] Refactor DecoderEmitter.cpp (PR #135510)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 12 22:52:32 PDT 2025


================
@@ -97,8 +97,8 @@ struct OperandInfo {
   bool HasCompleteDecoder;
   uint64_t InitValue;
 
-  OperandInfo(std::string D, bool HCD)
-      : Decoder(std::move(D)), HasCompleteDecoder(HCD), InitValue(0) {}
+  OperandInfo(const std::string &D, bool HCD)
----------------
topperc wrote:

This can lead to extra copies depending on how this constructor is used. If it's called with a temporary, the original code would move the string to the argument and then move it again to the class. The new code would copy it to the argument.

https://github.com/llvm/llvm-project/pull/135510


More information about the llvm-commits mailing list