From 3c9951db42dc660f9d4984885ed8bba6006c1b07 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Wed, 3 Apr 2024 14:55:49 +0200 Subject: [PATCH] Optimization in allocator comparison --- include/sparrow/allocator.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/sparrow/allocator.hpp b/include/sparrow/allocator.hpp index 14727bb9..ffc85634 100644 --- a/include/sparrow/allocator.hpp +++ b/include/sparrow/allocator.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -114,9 +115,9 @@ namespace sparrow bool equal(const interface& rhs) const override { - if (auto* p = dynamic_cast*>(&rhs)) + if (std::type_index(typeid(*this)) == std::type_index(typeid(rhs))) { - return p->m_alloc == m_alloc; + return m_alloc == static_cast*>(&rhs)->m_alloc; } return false; }