[lldb-vscode] Use a DenseMap to pacify overly aggressive linters
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 22 Apr 2021 11:01:16 +0000 (13:01 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 22 Apr 2021 11:07:39 +0000 (13:07 +0200)
Some linters get rather upset upon seeing
`std::unordered_map<const char*`, because it looks like a map of
strings but isn't. lldb uses interned strings so this is not a problem.
DenseMap is a better data structure for this anyways, so use that
instead.

lldb/tools/lldb-vscode/lldb-vscode.cpp

index 5f9e96b..4ceca38 100644 (file)
 #include <set>
 #include <sstream>
 #include <thread>
-#include <unordered_map>
 #include <vector>
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -2931,7 +2931,7 @@ void request_variables(const llvm::json::Object &request) {
     const int64_t end_idx = start_idx + ((count == 0) ? num_children : count);
 
     // We first find out which variable names are duplicated
-    std::unordered_map<const char *, int> variable_name_counts;
+    llvm::DenseMap<const char *, int> variable_name_counts;
     for (auto i = start_idx; i < end_idx; ++i) {
       lldb::SBValue variable = g_vsc.variables.GetValueAtIndex(i);
       if (!variable.IsValid())