[clang-tools-extra] [clangd] Add explicit std::move(...) to avoid a few copies (PR #180475)

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 8 23:50:38 PST 2026


https://github.com/serge-sans-paille created https://github.com/llvm/llvm-project/pull/180475

Moving an std::map is almost always profitable (DiagnosticToDiagRefMap).

Changes suggested by performance-use-std-move from #179467

>From adad1c6549d32b01e48dda23db431792394b2b48 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Mon, 9 Feb 2026 08:44:51 +0100
Subject: [PATCH] [clangd] Add explicit std::move(...) to avoid a few copies

Moving an std::map is almost always profitable (DiagnosticToDiagRefMap).

Changes suggested by performance-use-std-move from #179467
---
 clang-tools-extra/clangd/ClangdLSPServer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 761b07eceec83..ebd42abd2dd61 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1833,7 +1833,7 @@ void ClangdLSPServer::onDiagnosticsReady(PathRef File, llvm::StringRef Version,
   // Cache DiagRefMap
   {
     std::lock_guard<std::mutex> Lock(DiagRefMutex);
-    DiagRefMap[File] = LocalDiagMap;
+    DiagRefMap[File] = std::move(LocalDiagMap);
   }
 
   // Send a notification to the LSP client.



More information about the cfe-commits mailing list