[llvm] [Support] Drop unnecessary std::move in JSON.h (NFC) (PR #166027)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 1 14:54:36 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

fixUTF8 takes StringRef, so we do not need std::move here.

Identified with performance-move-const-arg.


---
Full diff: https://github.com/llvm/llvm-project/pull/166027.diff


1 Files Affected:

- (modified) llvm/include/llvm/Support/JSON.h (+2-2) 


``````````diff
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index a973c56ff5605..ecaadd272622f 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -318,7 +318,7 @@ class Value {
   Value(std::string V) : Type(T_String) {
     if (LLVM_UNLIKELY(!isUTF8(V))) {
       assert(false && "Invalid UTF-8 in value used as JSON");
-      V = fixUTF8(std::move(V));
+      V = fixUTF8(V);
     }
     create<std::string>(std::move(V));
   }
@@ -591,7 +591,7 @@ class ObjectKey {
   ObjectKey(std::string S) : Owned(new std::string(std::move(S))) {
     if (LLVM_UNLIKELY(!isUTF8(*Owned))) {
       assert(false && "Invalid UTF-8 in value used as JSON");
-      *Owned = fixUTF8(std::move(*Owned));
+      *Owned = fixUTF8(*Owned);
     }
     Data = *Owned;
   }

``````````

</details>


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


More information about the llvm-commits mailing list