[clang] [clang-tools-extra] [llvm] [Support][JSON] Use `std::map` for object storage (PR #171230)
Zixu Wang via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 9 22:08:16 PST 2025
================
@@ -94,9 +94,9 @@ class Value;
template <typename T> Value toJSON(const std::optional<T> &Opt);
/// An Object is a JSON object, which maps strings to heterogenous JSON values.
-/// It simulates DenseMap<ObjectKey, Value>. ObjectKey is a maybe-owned string.
+/// ObjectKey is a maybe-owned string.
class Object {
- using Storage = DenseMap<ObjectKey, Value, llvm::DenseMapInfo<StringRef>>;
+ using Storage = std::map<ObjectKey, Value>;
----------------
zixu-w wrote:
>From my understanding of the codebase, `ObjectKey` is always a string, but the generalization comes from the need to sometimes own the string. Before finding the `DenseMap` issue I also tried to optimize `ObjectKey` to make it just a `StringRef`, but sometimes the key can contain JSON escape sequence etc. etc. when it needs to be able to create a modified string as the key.
https://github.com/llvm/llvm-project/pull/171230
More information about the llvm-commits
mailing list