diff options
author | 2023-06-17 19:18:02 -0700 | |
---|---|---|
committer | 2023-06-17 19:18:02 -0700 | |
commit | 65f1e426849aa705c0fd7578134b8287f10d0176 (patch) | |
tree | 134aed84da5b4bf2310a2c8dd6a9f411e9572ba4 /src/bun.js/bindings/webcore/Node.h | |
parent | b0e8f596a2a3a5bd3f70d6d03de35c290d34d35c (diff) | |
parent | 065713aeca2ae3013bdf5b3d2f04263459631598 (diff) | |
download | bun-jarred/simplify.tar.gz bun-jarred/simplify.tar.zst bun-jarred/simplify.zip |
Merge branch 'main' into jarred/simplifyjarred/simplify
Diffstat (limited to 'src/bun.js/bindings/webcore/Node.h')
-rw-r--r-- | src/bun.js/bindings/webcore/Node.h | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/src/bun.js/bindings/webcore/Node.h b/src/bun.js/bindings/webcore/Node.h index df9917a25..509e04192 100644 --- a/src/bun.js/bindings/webcore/Node.h +++ b/src/bun.js/bindings/webcore/Node.h @@ -75,42 +75,20 @@ public: // mutable OptionSet<NodeFlag> m_nodeFlags; }; -#if ASSERT_ENABLED - -inline void adopted(Node* node) -{ - if (!node) - return; - ASSERT(!node->m_deletionHasBegun); - ASSERT(!node->m_inRemovedLastRefFunction); - node->m_adoptionIsRequired = false; -} - -#endif // ASSERT_ENABLED - ALWAYS_INLINE void Node::ref() const { - ASSERT(isMainThread()); - ASSERT(!m_deletionHasBegun); - ASSERT(!m_inRemovedLastRefFunction); - ASSERT(!m_adoptionIsRequired); + m_refCountAndParentBit += s_refCountIncrement; } ALWAYS_INLINE void Node::deref() const { - ASSERT(isMainThread()); - ASSERT(refCount()); - ASSERT(!m_deletionHasBegun); - ASSERT(!m_inRemovedLastRefFunction); - ASSERT(!m_adoptionIsRequired); + auto updatedRefCount = m_refCountAndParentBit - s_refCountIncrement; if (!updatedRefCount) { // Don't update m_refCountAndParentBit to avoid double destruction through use of Ref<T>/RefPtr<T>. // (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) -#if ASSERT_ENABLED - m_inRemovedLastRefFunction = true; -#endif + const_cast<Node&>(*this).removedLastRef(); return; } @@ -119,8 +97,7 @@ ALWAYS_INLINE void Node::deref() const ALWAYS_INLINE bool Node::hasOneRef() const { - ASSERT(!m_deletionHasBegun); - ASSERT(!m_inRemovedLastRefFunction); + return refCount() == 1; } |