Browse Source

minor changes (close #235)

Michele Caini 7 years ago
parent
commit
4d2666a0e3
1 changed files with 7 additions and 7 deletions
  1. 7 7
      src/entt/entity/sparse_set.hpp

+ 7 - 7
src/entt/entity/sparse_set.hpp

@@ -68,7 +68,7 @@ class sparse_set<Entity> {
         using direct_type = const std::vector<Entity>;
         using index_type = typename traits_type::difference_type;
 
-        iterator(direct_type *ref, index_type idx) ENTT_NOEXCEPT
+        iterator(direct_type *ref, const index_type idx) ENTT_NOEXCEPT
             : direct{ref}, index{idx}
         {}
 
@@ -163,7 +163,7 @@ class sparse_set<Entity> {
         index_type index;
     };
 
-    void assure(std::size_t page) {
+    void assure(const std::size_t page) {
         if(!(page < reverse.size())) {
             reverse.resize(page+1);
         }
@@ -175,7 +175,7 @@ class sparse_set<Entity> {
         }
     }
 
-    auto index(Entity entt) const ENTT_NOEXCEPT {
+    auto index(const Entity entt) const ENTT_NOEXCEPT {
         const auto identifier = entt & traits_type::entity_mask;
         const auto page = size_type(identifier / entt_per_page);
         const auto offset = size_type(identifier & (entt_per_page - 1));
@@ -459,8 +459,8 @@ public:
         ENTT_ASSERT(has(entt));
         auto [from_page, from_offset] = index(entt);
         auto [to_page, to_offset] = index(direct.back());
-        std::swap(direct[size_type(reverse[from_page].first[from_offset])], direct.back());
-        std::swap(reverse[from_page].first[from_offset], reverse[to_page].first[to_offset]);
+        direct[size_type(reverse[from_page].first[from_offset])] = direct.back();
+        reverse[to_page].first[to_offset] = reverse[from_page].first[from_offset];
         reverse[from_page].first[from_offset] = null;
         reverse[from_page].second--;
         direct.pop_back();
@@ -576,7 +576,7 @@ class sparse_set<Entity, Type>: public sparse_set<Entity> {
         using instance_type = std::conditional_t<Const, const std::vector<Type>, std::vector<Type>>;
         using index_type = typename traits_type::difference_type;
 
-        iterator(instance_type *ref, index_type idx) ENTT_NOEXCEPT
+        iterator(instance_type *ref, const index_type idx) ENTT_NOEXCEPT
             : instances{ref}, index{idx}
         {}
 
@@ -678,7 +678,7 @@ class sparse_set<Entity, Type>: public sparse_set<Entity> {
         using instance_type = std::conditional_t<Const, const Type, Type>;
         using index_type = typename traits_type::difference_type;
 
-        iterator(instance_type *ref, index_type idx) ENTT_NOEXCEPT
+        iterator(instance_type *ref, const index_type idx) ENTT_NOEXCEPT
             : instance{ref}, index{idx}
         {}