The remaining use of ConstString in StructuredData is the Dictionary
class. Internally it's backed by a std::map<ConstString, ObjectSP>.
I propose that we replace it with a llvm::StringMap<ObjectSP>.
Many StructuredData::Dictionary objects are ephemeral and only exist for
a short amount of time. Many of these Dictionaries are only produced
once and are never used again. That leaves us with a lot of string data
in the ConstString StringPool that is sitting there never to be used
again. Even if the same string is used many times for keys of different
Dictionary objects, that is something we can measure and adjust for
instead of assuming that every key may be reused at some point in the
future.
Quick comparisons of key data is likely not a concern with Dictionary,
but the use of llvm::StringMap means that lookups should be fast with
its hashing strategy.
Switching to a llvm::StringMap meant that the iteration order may be
different. To account for this when serializing/dumping the dictionary,
I added some code to sort the output by key before emitting anything.
Since we are touching this line anyway, could you replace this with
This has a bit less cognitive burden IMO