From 9c59978f495204eb0e91bd7df396a176e8fad2bf Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 15 Aug 2013 16:41:19 +0200 Subject: [PATCH] smalloc: don't do Has(key), then Get(key) Don't check for the key first before retrieving it. Just fetch it and check that it has the type we expect. --- src/smalloc.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/smalloc.cc b/src/smalloc.cc index c4c1663..8100fbf 100644 --- a/src/smalloc.cc +++ b/src/smalloc.cc @@ -301,11 +301,14 @@ void AllocDispose(const FunctionCallbackInfo& args) { void AllocDispose(Handle obj) { HandleScope scope(node_isolate); - if (using_alloc_cb && obj->Has(smalloc_sym)) { - Local ext = obj->GetHiddenValue(smalloc_sym).As(); - CallbackInfo* cb_info = static_cast(ext->Value()); - TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info); - return; + if (using_alloc_cb) { + Local ext_v = obj->GetHiddenValue(smalloc_sym); + if (ext_v->IsExternal()) { + Local ext = ext_v.As(); + CallbackInfo* cb_info = static_cast(ext->Value()); + TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info); + return; + } } char* data = static_cast(obj->GetIndexedPropertiesExternalArrayData()); -- 2.7.4