Skip to content

Commit

Permalink
Optimization in allocator comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille committed Apr 3, 2024
1 parent ad7dc53 commit 3c9951d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/sparrow/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cstdint>
#include <memory>
#include <memory_resource>
#include <typeindex>
#include <type_traits>
#include <variant>

Expand Down Expand Up @@ -114,9 +115,9 @@ namespace sparrow

bool equal(const interface& rhs) const override
{
if (auto* p = dynamic_cast<const impl<A>*>(&rhs))
if (std::type_index(typeid(*this)) == std::type_index(typeid(rhs)))
{
return p->m_alloc == m_alloc;
return m_alloc == static_cast<const impl<A>*>(&rhs)->m_alloc;
}
return false;
}
Expand Down

0 comments on commit 3c9951d

Please sign in to comment.