diff --git a/AK/RefCounted.h b/AK/RefCounted.h index 95f71830835..0908517303b 100644 --- a/AK/RefCounted.h +++ b/AK/RefCounted.h @@ -69,9 +69,6 @@ public: that->will_be_destroyed(); delete static_cast(this); return true; - } else if (new_ref_count == 1) { - if constexpr (requires { that->one_ref_left(); }) - that->one_ref_left(); } return false; } diff --git a/Kernel/Library/ListedRefCounted.h b/Kernel/Library/ListedRefCounted.h index 154d3de60eb..ea95f18ad35 100644 --- a/Kernel/Library/ListedRefCounted.h +++ b/Kernel/Library/ListedRefCounted.h @@ -49,9 +49,6 @@ public: if constexpr (requires { that->will_be_destroyed(); }) that->will_be_destroyed(); delete that; - } else if (new_ref_count == 1) { - if constexpr (requires { that->one_ref_left(); }) - that->one_ref_left(); } return new_ref_count == 0; } diff --git a/Kernel/Library/ThreadSafeRefCounted.h b/Kernel/Library/ThreadSafeRefCounted.h index 65690bb0909..18ebc5db27f 100644 --- a/Kernel/Library/ThreadSafeRefCounted.h +++ b/Kernel/Library/ThreadSafeRefCounted.h @@ -77,10 +77,6 @@ public: delete that; return true; } - if (new_ref_count == 1) { - if constexpr (requires { that->one_ref_left(); }) - that->one_ref_left(); - } return false; } }; diff --git a/Tests/AK/TestRefPtr.cpp b/Tests/AK/TestRefPtr.cpp index 64a96cf2ba2..5d3c0a0205b 100644 --- a/Tests/AK/TestRefPtr.cpp +++ b/Tests/AK/TestRefPtr.cpp @@ -17,10 +17,8 @@ struct Object2 : Object { }; struct SelfAwareObject : public RefCounted { - void one_ref_left() { m_has_one_ref_left = true; } void will_be_destroyed() { ++num_destroyed; } - bool m_has_one_ref_left = false; static size_t num_destroyed; }; size_t SelfAwareObject::num_destroyed = 0; @@ -132,17 +130,14 @@ TEST_CASE(self_observers) { RefPtr object = adopt_ref(*new SelfAwareObject); EXPECT_EQ(object->ref_count(), 1u); - EXPECT_EQ(object->m_has_one_ref_left, false); EXPECT_EQ(SelfAwareObject::num_destroyed, 0u); object->ref(); EXPECT_EQ(object->ref_count(), 2u); - EXPECT_EQ(object->m_has_one_ref_left, false); EXPECT_EQ(SelfAwareObject::num_destroyed, 0u); object->unref(); EXPECT_EQ(object->ref_count(), 1u); - EXPECT_EQ(object->m_has_one_ref_left, true); EXPECT_EQ(SelfAwareObject::num_destroyed, 0u); } EXPECT_EQ(SelfAwareObject::num_destroyed, 1u);