Browse Source

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.
v0.11.6-release
Ben Noordhuis 12 years ago
parent
commit
9c59978f49
  1. 7
      src/smalloc.cc

7
src/smalloc.cc

@ -301,12 +301,15 @@ void AllocDispose(const FunctionCallbackInfo<Value>& args) {
void AllocDispose(Handle<Object> obj) { void AllocDispose(Handle<Object> obj) {
HandleScope scope(node_isolate); HandleScope scope(node_isolate);
if (using_alloc_cb && obj->Has(smalloc_sym)) { if (using_alloc_cb) {
Local<External> ext = obj->GetHiddenValue(smalloc_sym).As<External>(); Local<Value> ext_v = obj->GetHiddenValue(smalloc_sym);
if (ext_v->IsExternal()) {
Local<External> ext = ext_v.As<External>();
CallbackInfo* cb_info = static_cast<CallbackInfo*>(ext->Value()); CallbackInfo* cb_info = static_cast<CallbackInfo*>(ext->Value());
TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info); TargetFreeCallback(node_isolate, &cb_info->p_obj, cb_info);
return; return;
} }
}
char* data = static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData()); char* data = static_cast<char*>(obj->GetIndexedPropertiesExternalArrayData());
size_t length = obj->GetIndexedPropertiesExternalArrayDataLength(); size_t length = obj->GetIndexedPropertiesExternalArrayDataLength();

Loading…
Cancel
Save