Răsfoiți Sursa

sigh: slightly reduce instantiations

Michele Caini 3 ani în urmă
părinte
comite
6e1a774921
1 a modificat fișierele cu 4 adăugiri și 5 ștergeri
  1. 4 5
      src/entt/signal/sigh.hpp

+ 4 - 5
src/entt/signal/sigh.hpp

@@ -3,7 +3,6 @@
 
 #include <algorithm>
 #include <functional>
-#include <iterator>
 #include <type_traits>
 #include <utility>
 #include <vector>
@@ -362,7 +361,7 @@ private:
 template<typename Ret, typename... Args, typename Allocator>
 class sink<sigh<Ret(Args...), Allocator>> {
     using signal_type = sigh<Ret(Args...), Allocator>;
-    using difference_type = typename std::iterator_traits<typename decltype(signal_type::calls)::iterator>::difference_type;
+    using difference_type = typename signal_type::container_type::difference_type;
 
     template<auto Candidate, typename Type>
     static void release(Type value_or_instance, void *signal) {
@@ -406,7 +405,7 @@ public:
         const auto it = std::find(calls.cbegin(), calls.cend(), std::move(call));
 
         sink other{*this};
-        other.offset = std::distance(it, calls.cend());
+        other.offset = calls.cend() - it;
         return other;
     }
 
@@ -427,7 +426,7 @@ public:
         const auto it = std::find(calls.cbegin(), calls.cend(), std::move(call));
 
         sink other{*this};
-        other.offset = std::distance(it, calls.cend());
+        other.offset = calls.cend() - it;
         return other;
     }
 
@@ -460,7 +459,7 @@ public:
                 return delegate.data() == value_or_instance;
             });
 
-            other.offset = std::distance(it, calls.cend());
+            other.offset = calls.cend() - it;
         }
 
         return other;