Skip to content

Commit

Permalink
Added a debugging helper function Pool::findObject()
Browse files Browse the repository at this point in the history
  • Loading branch information
corporateshark committed Nov 25, 2023
1 parent 208cf65 commit 4a5cdea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lvk/Pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ class Pool {
assert(handle.gen() == objects_[index].gen_); // accessing deleted object
return &objects_[index].obj_;
}
Handle<ObjectType> findObject(const ImplObjectType* obj) {
if (!obj)
return {};

for (size_t idx = 0; idx != objects_.size(); idx++) {
if (objects_[idx].obj_ == *obj) {
return Handle<ObjectType>((uint32_t)idx, objects_[idx].gen_);
}
}

return {};
}
void clear() {
objects_.clear();
freeListHead_ = kListEndSentinel;
Expand Down

0 comments on commit 4a5cdea

Please sign in to comment.