tint::CloneContext: Use Hashmap::Generation()
Instead of tracking its own generation. Change-Id: Iea9710fd6665cfc13fb72741b8a80c6dde4f64e9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100902 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
4e0335c5af
commit
cd716e6f01
|
@ -541,6 +541,8 @@ class CloneContext {
|
||||||
|
|
||||||
/// VectorListTransforms is a map of utils::Vector pointer to transforms for that list
|
/// VectorListTransforms is a map of utils::Vector pointer to transforms for that list
|
||||||
struct VectorListTransforms {
|
struct VectorListTransforms {
|
||||||
|
using Map = utils::Hashmap<const void*, ListTransforms, 4>;
|
||||||
|
|
||||||
/// An accessor to the VectorListTransforms map.
|
/// An accessor to the VectorListTransforms map.
|
||||||
/// Index caches the last map lookup, and will only re-search the map if the transform map
|
/// Index caches the last map lookup, and will only re-search the map if the transform map
|
||||||
/// was modified since the last lookup.
|
/// was modified since the last lookup.
|
||||||
|
@ -560,44 +562,36 @@ class CloneContext {
|
||||||
private:
|
private:
|
||||||
friend VectorListTransforms;
|
friend VectorListTransforms;
|
||||||
|
|
||||||
Index(const void* list,
|
Index(const void* list, Map* map)
|
||||||
VectorListTransforms& vlt,
|
: list_(list),
|
||||||
uint32_t generation,
|
map_(map),
|
||||||
const ListTransforms* cached)
|
generation_(map->Generation()),
|
||||||
: list_(list), vlt_(vlt), generation_(generation), cached_(cached) {}
|
cached_(map_->Find(list)) {}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
if (vlt_.generation_ != generation_) {
|
if (map_->Generation() != generation_) {
|
||||||
cached_ = vlt_.map_.Find(list_);
|
cached_ = map_->Find(list_);
|
||||||
generation_ = vlt_.generation_;
|
generation_ = map_->Generation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* list_;
|
const void* list_;
|
||||||
VectorListTransforms& vlt_;
|
Map* map_;
|
||||||
uint32_t generation_;
|
uint64_t generation_;
|
||||||
const ListTransforms* cached_;
|
const ListTransforms* cached_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Edit returns a reference to the ListTransforms for the given vector pointer and
|
/// Edit returns a reference to the ListTransforms for the given vector pointer and
|
||||||
/// increments #list_transform_generation_ signalling that the list transforms have been
|
/// increments #list_transform_generation_ signalling that the list transforms have been
|
||||||
/// modified.
|
/// modified.
|
||||||
inline ListTransforms& Edit(const void* list) {
|
inline ListTransforms& Edit(const void* list) { return map_.GetOrZero(list); }
|
||||||
generation_++;
|
|
||||||
return map_.GetOrZero(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @returns an Index to the transforms for the given list.
|
/// @returns an Index to the transforms for the given list.
|
||||||
inline Index Find(const void* list) {
|
inline Index Find(const void* list) { return Index{list, &map_}; }
|
||||||
return Index{list, *this, generation_, map_.Find(list)};
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The map of vector pointer to ListTransforms
|
/// The map of vector pointer to ListTransforms
|
||||||
utils::Hashmap<const void*, ListTransforms, 4> map_;
|
Map map_;
|
||||||
|
|
||||||
/// A counter that's incremented each time list transforms are modified.
|
|
||||||
uint32_t generation_ = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A map of object in #src to functions that create their replacement in #dst
|
/// A map of object in #src to functions that create their replacement in #dst
|
||||||
|
|
Loading…
Reference in New Issue