Commit 17a7a782 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/tl/formula.hh: Handle saturation of refs_.

parent e5aebfd5
......@@ -53,6 +53,7 @@
#include <list>
#include <cstddef>
#include <initializer_list>
#include <limits>
namespace spot
{
......@@ -108,17 +109,20 @@ namespace spot
public:
const fnode* clone() const
{
// Saturate.
++refs_;
if (SPOT_UNLIKELY(!refs_))
saturated_ = 1;
return this;
}
void destroy() const
{
// last reference to a node that is not a constant?
if (SPOT_UNLIKELY(!refs_ && id_ > 2))
destroy_aux();
else
if (SPOT_LIKELY(refs_))
--refs_;
else if (SPOT_LIKELY(id_ > 2) && SPOT_LIKELY(!saturated_))
// last reference to a node that is not a constant
destroy_aux();
}
static constexpr uint8_t unbounded()
......@@ -443,7 +447,7 @@ namespace spot
op op_; // operator
uint8_t min_; // range minimum (for star-like operators)
uint8_t max_; // range maximum;
//uint8_t unused_;
mutable uint8_t saturated_ = 0;
uint16_t size_; // number of children
mutable uint16_t refs_ = 0; // reference count - 1;
size_t id_; // Also used as hash.
......
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