summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim King <taking@google.com>2016-11-11 14:46:30 -0800
committerTim King <taking@google.com>2016-11-11 14:46:30 -0800
commit0c65c780c6c7c52c26edf6ec0b8f45ef9fb496cf (patch)
tree105d1d786a99d523ce2b6ad21bbbfe50081947f7 /src
parent16e809f698060645812667925b3e0c4d403ee71a (diff)
Speeding up the common branches for inc().
Diffstat (limited to 'src')
-rw-r--r--src/expr/node_value.h23
1 files changed, 12 insertions, 11 deletions
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);
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback