From ccd632f2784f6f3eea7ef62fbddb38844f8b6e9d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 26 Jan 2010 12:00:17 -0800 Subject: [PATCH] Simplify ObjectWrap; make fewer Weak callbacks --- src/node_object_wrap.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h index c392055a63..457b234581 100644 --- a/src/node_object_wrap.h +++ b/src/node_object_wrap.h @@ -13,12 +13,10 @@ class ObjectWrap { } virtual ~ObjectWrap ( ) { - if (!handle_.IsEmpty()) { - assert(handle_.IsNearDeath()); - handle_->SetInternalField(0, v8::Undefined()); - handle_.Dispose(); - handle_.Clear(); - } + assert(handle_.IsNearDeath()); + handle_->SetInternalField(0, v8::Undefined()); + handle_.Dispose(); + handle_.Clear(); } protected: @@ -37,11 +35,6 @@ class ObjectWrap { assert(handle->InternalFieldCount() > 0); handle_ = v8::Persistent::New(handle); handle_->SetInternalField(0, v8::External::New(this)); - MakeWeak(); - } - - inline void MakeWeak (void) - { handle_.MakeWeak(this, WeakCallback); } @@ -53,7 +46,6 @@ class ObjectWrap { assert(!handle_.IsEmpty()); assert(handle_.IsWeak()); refs_++; - MakeWeak(); } /* Unref() marks an object as detached from the event loop. This is its @@ -83,8 +75,6 @@ class ObjectWrap { assert(value == obj->handle_); if (obj->refs_ == 0) { delete obj; - } else { - obj->MakeWeak(); } } };