From 206311f0f477e0f2c8318749dbb1ae66c34354e4 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 23 Aug 2018 00:55:10 +0200 Subject: [PATCH] src: use default parameters for CreateIsolateData --- src/node.cc | 19 +++++-------------- src/node.h | 12 ++---------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/node.cc b/src/node.cc index b60024171046ff..4a7b6261be4365 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3229,25 +3229,16 @@ void FreeArrayBufferAllocator(ArrayBufferAllocator* allocator) { } -IsolateData* CreateIsolateData(Isolate* isolate, uv_loop_t* loop) { - return new IsolateData(isolate, loop, nullptr); -} - - -IsolateData* CreateIsolateData( - Isolate* isolate, - uv_loop_t* loop, - MultiIsolatePlatform* platform) { - return new IsolateData(isolate, loop, platform); -} - - IsolateData* CreateIsolateData( Isolate* isolate, uv_loop_t* loop, MultiIsolatePlatform* platform, ArrayBufferAllocator* allocator) { - return new IsolateData(isolate, loop, platform, allocator->zero_fill_field()); + return new IsolateData( + isolate, + loop, + platform, + allocator != nullptr ? allocator->zero_fill_field() : nullptr); } diff --git a/src/node.h b/src/node.h index ab82be7ac4d30f..74403a6e48d3b8 100644 --- a/src/node.h +++ b/src/node.h @@ -257,19 +257,11 @@ NODE_EXTERN v8::Local NewContext( // If `platform` is passed, it will be used to register new Worker instances. // It can be `nullptr`, in which case creating new Workers inside of // Environments that use this `IsolateData` will not work. -// TODO(helloshuangzi): switch to default parameters. -NODE_EXTERN IsolateData* CreateIsolateData( - v8::Isolate* isolate, - struct uv_loop_s* loop); -NODE_EXTERN IsolateData* CreateIsolateData( - v8::Isolate* isolate, - struct uv_loop_s* loop, - MultiIsolatePlatform* platform); NODE_EXTERN IsolateData* CreateIsolateData( v8::Isolate* isolate, struct uv_loop_s* loop, - MultiIsolatePlatform* platform, - ArrayBufferAllocator* allocator); + MultiIsolatePlatform* platform = nullptr, + ArrayBufferAllocator* allocator = nullptr); NODE_EXTERN void FreeIsolateData(IsolateData* isolate_data); // TODO(addaleax): Add an official variant using STL containers, and move