From 355c7b59aa7fbab8be21eee683754a088ffec0d6 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Wed, 10 Apr 2019 13:56:19 +0200 Subject: [PATCH] cleanup --- TODO | 2 +- src/entt/entity/sparse_set.hpp | 12 ------------ test/entt/entity/sparse_set.cpp | 25 ------------------------- 3 files changed, 1 insertion(+), 38 deletions(-) diff --git a/TODO b/TODO index cf14cf94a..43469c5a5 100644 --- a/TODO +++ b/TODO @@ -19,5 +19,5 @@ * review sparse set to allow customization (mix pack in the spec, base is position only) - non-owning groups can iterate pages and skip empty ones, this should mitigate the lack of the packed array * review 64 bit id: user defined area + dedicated member on the registry to set it -* remove entity function from sparse sets (no longer required) * reactive systems +* optimize groups access in case there are no named types (use family for direct access) diff --git a/src/entt/entity/sparse_set.hpp b/src/entt/entity/sparse_set.hpp index 5e7974ed7..b41fcd42f 100644 --- a/src/entt/entity/sparse_set.hpp +++ b/src/entt/entity/sparse_set.hpp @@ -860,18 +860,6 @@ public: return const_cast(std::as_const(*this).raw()); } - /** - * @brief Returns the entity to which a given component is assigned. - * @param instance A valid reference to an object. - * @return A valid entity identifier if the instance belongs to the sparse - * set, the null entity otherwise. - */ - inline entity_type entity(const object_type &instance) { - const auto address = std::addressof(instance); - const bool valid = !(instances.data() > address) && (address < (instances.data() + instances.size())); - return valid ? sparse_set::data()[address - instances.data()] : null; - } - /** * @brief Returns an iterator to the beginning. * diff --git a/test/entt/entity/sparse_set.cpp b/test/entt/entity/sparse_set.cpp index 905c1975f..49ac29cfe 100644 --- a/test/entt/entity/sparse_set.cpp +++ b/test/entt/entity/sparse_set.cpp @@ -486,31 +486,6 @@ TEST(SparseSetWithType, Functionalities) { other = std::move(set); } -TEST(SparseSetWithType, EntityFromComponent) { - entt::sparse_set set; - typename entt::sparse_set::entity_type invalid = entt::null; - - set.reserve(3); - - const auto &first = set.construct(42, 3); - const auto &second = set.construct(3, 9); - const auto &third = set.construct(99, 7); - - ASSERT_NE(set.entity(first), invalid); - ASSERT_EQ(set.get(set.entity(first)), first); - ASSERT_EQ(&set.get(set.entity(first)), &first); - - ASSERT_NE(set.entity(second), invalid); - ASSERT_EQ(set.get(set.entity(second)), second); - ASSERT_EQ(&set.get(set.entity(second)), &second); - - ASSERT_NE(set.entity(third), invalid); - ASSERT_EQ(set.get(set.entity(third)), third); - ASSERT_EQ(&set.get(set.entity(third)), &third); - - ASSERT_EQ(set.entity(0), invalid); -} - TEST(SparseSetWithType, EmptyType) { entt::sparse_set set;