return a.id < b.id;
}
-StackDepotReverseMap::StackDepotReverseMap() {
+void StackDepotReverseMap::Init() const {
+ if (LIKELY(map_.capacity()))
+ return;
map_.reserve(StackDepotGetStats().n_uniq_ids + 100);
for (int idx = 0; idx < StackDepot::kTabSize; idx++) {
atomic_uintptr_t *p = &theDepot.tab[idx];
}
StackTrace StackDepotReverseMap::Get(u32 id) const {
+ Init();
if (!map_.size())
return StackTrace();
IdDescPair pair = {id, nullptr};
// which were stored before it was instantiated.
class StackDepotReverseMap {
public:
- StackDepotReverseMap();
+ StackDepotReverseMap() = default;
StackTrace Get(u32 id) const;
private:
static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
};
- InternalMmapVector<IdDescPair> map_;
+ void Init() const;
+
+ mutable InternalMmapVector<IdDescPair> map_;
// Disallow evil constructors.
StackDepotReverseMap(const StackDepotReverseMap&);