This is like CachedHashStringRef, but owns its data.
This lets us use strings inside of DenseMaps.
Differential D25645
[ADT] Add CachedHashString. jlebar on Oct 15 2016, 3:08 PM. Authored by
Details This is like CachedHashStringRef, but owns its data. This lets us use strings inside of DenseMaps.
Diff Detail
Event Timeline
Comment Actions Rafael, Tim and I were looking for a second opinion -- does this seem to you like a sane thing to do? The immediate problem I'm trying to solve here is to convert code that's using SmallSetVector<std::string>, which doesn't work after converting SmallSetVector to use DenseSet, because you can't store an std::string in a DenseSet. Longer term, I hope to use something like this class to let us replace StringSet, StringMap, &co, but what we end up with in order to make that work may look quite different from this. I was just planning to change it as necessary.
Comment Actions Address Rafael's comments (get rid of explicit operators in favor of implicit Comment Actions Couldn't CachedHashString just wrap a CachedHashStringRef? Or even have a single implementation: template<bool Owning> class CachedHashStringRefBase { ... ~CachedHashStringRefBase() { if (owning) delete... } using CachedHashStringRef = CachedHashStringRefBase<false>; using CachedHashString = CachedHashStringRefBase<true>;
Comment Actions Sorry, forgot to respond to this. I don't think this is a good idea, because the two classes do not have the same API. In particular, CachedHashString has a conversion to CachedHashStringRef. We would have to enable-if this away. Also the bodies of about half of the functions would be different. At this point we would not be gaining much from this additional layer of indirection. |