Commit 3ad002be authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

formula: speedup == and !=

Allow < and > to work with nullptr as well.

* src/ltlast/formula.hh: Here.
parent 6a3c3095
......@@ -684,27 +684,43 @@ namespace spot
bool operator<(const formula& other) const noexcept
{
if (SPOT_UNLIKELY(!other.ptr_))
return false;
if (SPOT_UNLIKELY(!ptr_))
return true;
return id() < other.id();
}
bool operator<=(const formula& other) const noexcept
{
if (SPOT_UNLIKELY(!other.ptr_))
return !ptr_;
if (SPOT_UNLIKELY(!ptr_))
return true;
return id() <= other.id();
}
bool operator>(const formula& other) const noexcept
{
if (SPOT_UNLIKELY(!ptr_))
return false;
if (SPOT_UNLIKELY(!other.ptr_))
return true;
return id() > other.id();
}
bool operator>=(const formula& other) const noexcept
{
if (SPOT_UNLIKELY(!ptr_))
return !!other.ptr_;
if (SPOT_UNLIKELY(!other.ptr_))
return true;
return id() >= other.id();
}
bool operator==(const formula& other) const noexcept
{
return id() == other.id();
return other.ptr_ == ptr_;
}
bool operator==(std::nullptr_t) const noexcept
......@@ -714,7 +730,7 @@ namespace spot
bool operator!=(const formula& other) const noexcept
{
return id() != other.id();
return other.ptr_ != ptr_;
}
bool operator!=(std::nullptr_t) const noexcept
......@@ -722,6 +738,11 @@ namespace spot
return ptr_ != nullptr;
}
operator bool() const
{
return ptr_ != nullptr;
}
/////////////////////////
// Forwarded functions //
/////////////////////////
......@@ -929,11 +950,6 @@ namespace spot
static formula sugar_equal(const formula& b, uint8_t min, uint8_t max);
operator bool() const
{
return ptr_ != nullptr;
}
#ifndef SWIG
const fnode* to_node_()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment