From: Tim King Date: Fri, 11 Nov 2016 22:46:30 +0000 (-0800) Subject: Speeding up the common branches for inc(). X-Git-Tag: cvc5-1.0.0~5983^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c65c780c6c7c52c26edf6ec0b8f45ef9fb496cf;p=cvc5.git Speeding up the common branches for inc(). --- diff --git a/src/expr/node_value.h b/src/expr/node_value.h index 8f1df0fff..79ce8cb4f 100644 --- a/src/expr/node_value.h +++ b/src/expr/node_value.h @@ -298,9 +298,10 @@ public: private: /** - * RAII guard that increases the reference count if the reference count to be > 0. - * Otherwise, this does nothing. This does not just increment the reference - * count to avoid maxing out the d_rc field. This is only for low level functions. + * RAII guard that increases the reference count if the reference count to be + * > 0. Otherwise, this does nothing. This does not just increment the + * reference count to avoid maxing out the d_rc field. This is only for low + * level functions. */ class RefCountGuard { NodeValue* d_nv; @@ -422,15 +423,15 @@ inline void NodeValue::inc() { "NodeValue is currently being deleted " "and increment is being called on it. Don't Do That!"); // FIXME multithreading - if(__builtin_expect( ( d_rc < MAX_RC ), true )) { + if (__builtin_expect((d_rc < MAX_RC - 1), true)) { ++d_rc; - if(__builtin_expect( ( d_rc == MAX_RC ), false )) { - Assert(NodeManager::currentNM() != NULL, - "No current NodeManager on incrementing of NodeValue: " - "maybe a public CVC4 interface function is missing a " - "NodeManagerScope ?"); - NodeManager::currentNM()->markRefCountMaxedOut(this); - } + } else if (__builtin_expect((d_rc == MAX_RC - 1), false)) { + ++d_rc; + Assert(NodeManager::currentNM() != NULL, + "No current NodeManager on incrementing of NodeValue: " + "maybe a public CVC4 interface function is missing a " + "NodeManagerScope ?"); + NodeManager::currentNM()->markRefCountMaxedOut(this); } }