From 3de9dd9c8dd1181cacb1046f93dd17d0d594e39e 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 fa3ba022fe7e23..70750cc87179ca 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -243,9 +243,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 9660cc386cef82..149f542d841607 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -92,29 +92,29 @@ void StreamResource::RemoveStreamListener(StreamListener* listener) { } uv_buf_t StreamResource::EmitAlloc(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; return listener_->OnStreamAlloc(suggested_size); } 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); } void StreamResource::EmitAfterWrite(WriteWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterWrite(w, status); } void StreamResource::EmitAfterShutdown(ShutdownWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterShutdown(w, status); } void StreamResource::EmitWantsWrite(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamWantsWrite(suggested_size); }