formula: speedup == and !=
Allow < and > to work with nullptr as well. * src/ltlast/formula.hh: Here.
This commit is contained in:
parent
6a3c30951e
commit
3ad002be5f
1 changed files with 23 additions and 7 deletions
|
|
@ -684,27 +684,43 @@ namespace spot
|
||||||
|
|
||||||
bool operator<(const formula& other) const noexcept
|
bool operator<(const formula& other) const noexcept
|
||||||
{
|
{
|
||||||
|
if (SPOT_UNLIKELY(!other.ptr_))
|
||||||
|
return false;
|
||||||
|
if (SPOT_UNLIKELY(!ptr_))
|
||||||
|
return true;
|
||||||
return id() < other.id();
|
return id() < other.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<=(const formula& other) const noexcept
|
bool operator<=(const formula& other) const noexcept
|
||||||
{
|
{
|
||||||
|
if (SPOT_UNLIKELY(!other.ptr_))
|
||||||
|
return !ptr_;
|
||||||
|
if (SPOT_UNLIKELY(!ptr_))
|
||||||
|
return true;
|
||||||
return id() <= other.id();
|
return id() <= other.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator>(const formula& other) const noexcept
|
bool operator>(const formula& other) const noexcept
|
||||||
{
|
{
|
||||||
|
if (SPOT_UNLIKELY(!ptr_))
|
||||||
|
return false;
|
||||||
|
if (SPOT_UNLIKELY(!other.ptr_))
|
||||||
|
return true;
|
||||||
return id() > other.id();
|
return id() > other.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator>=(const formula& other) const noexcept
|
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();
|
return id() >= other.id();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const formula& other) const noexcept
|
bool operator==(const formula& other) const noexcept
|
||||||
{
|
{
|
||||||
return id() == other.id();
|
return other.ptr_ == ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(std::nullptr_t) const noexcept
|
bool operator==(std::nullptr_t) const noexcept
|
||||||
|
|
@ -714,7 +730,7 @@ namespace spot
|
||||||
|
|
||||||
bool operator!=(const formula& other) const noexcept
|
bool operator!=(const formula& other) const noexcept
|
||||||
{
|
{
|
||||||
return id() != other.id();
|
return other.ptr_ != ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(std::nullptr_t) const noexcept
|
bool operator!=(std::nullptr_t) const noexcept
|
||||||
|
|
@ -722,6 +738,11 @@ namespace spot
|
||||||
return ptr_ != nullptr;
|
return ptr_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator bool() const
|
||||||
|
{
|
||||||
|
return ptr_ != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Forwarded functions //
|
// Forwarded functions //
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
@ -929,11 +950,6 @@ namespace spot
|
||||||
|
|
||||||
static formula sugar_equal(const formula& b, uint8_t min, uint8_t max);
|
static formula sugar_equal(const formula& b, uint8_t min, uint8_t max);
|
||||||
|
|
||||||
operator bool() const
|
|
||||||
{
|
|
||||||
return ptr_ != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
const fnode* to_node_()
|
const fnode* to_node_()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue