From b6300793fb3317d5b247ec4fa10d9b7e19ef91a1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 8 May 2020 05:56:31 +0200 Subject: [PATCH] src: remove unnecessary Isolate::GetCurrent() calls These calls are unnecessary in Release mode but would still have been included, so move them to the `DebugSealHandleScope` constructor. PR-URL: https://github.com/nodejs/node/pull/33298 Reviewed-By: Daniel Bevenius Reviewed-By: Colin Ihrig Reviewed-By: David Carlier Reviewed-By: Michael Dawson --- src/node_internals.h | 4 ++-- src/stream_base-inl.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index 9f4f3337172f1b..c1555b312e2f22 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -246,9 +246,9 @@ class InternalCallbackScope { class DebugSealHandleScope { public: - explicit inline DebugSealHandleScope(v8::Isolate* isolate) + explicit inline DebugSealHandleScope(v8::Isolate* isolate = nullptr) #ifdef DEBUG - : actual_scope_(isolate) + : actual_scope_(isolate != nullptr ? isolate : v8::Isolate::GetCurrent()) #endif {} diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 41eeb1e0ef5710..ef7a5e4c7a87f2 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -113,29 +113,29 @@ inline void StreamResource::RemoveStreamListener(StreamListener* listener) { } inline uv_buf_t StreamResource::EmitAlloc(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; return listener_->OnStreamAlloc(suggested_size); } inline void StreamResource::EmitRead(ssize_t nread, const uv_buf_t& buf) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; if (nread > 0) bytes_read_ += static_cast(nread); listener_->OnStreamRead(nread, buf); } inline void StreamResource::EmitAfterWrite(WriteWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterWrite(w, status); } inline void StreamResource::EmitAfterShutdown(ShutdownWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterShutdown(w, status); } inline void StreamResource::EmitWantsWrite(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamWantsWrite(suggested_size); }