From: Ben Noordhuis Date: Thu, 15 Aug 2013 14:41:19 +0000 (+0200) Subject: smalloc: don't do Has(key), then Get(key) X-Git-Tag: v0.11.6~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c59978f495204eb0e91bd7df396a176e8fad2bf;p=platform%2Fupstream%2Fnodejs.git 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. --- 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());