From bf360d2e151f9025a990e671147117139e596bfe Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 26 Jun 2018 00:07:36 +0200 Subject: [PATCH] src: slightly simplify `FSEventWrap` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t need to track `initialized_`, `HandleWrap` already does that for us. PR-URL: https://github.com/nodejs/node/pull/21533 Reviewed-By: Eugene Ostroukhov Reviewed-By: Joyee Cheung Reviewed-By: Anatoli Papirovski Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/fs_event_wrap.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index a9ac67957335b3..164614ae81145f 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -55,7 +55,6 @@ class FSEventWrap: public HandleWrap { Local context); static void New(const FunctionCallbackInfo& args); static void Start(const FunctionCallbackInfo& args); - static void Close(const FunctionCallbackInfo& args); static void GetInitialized(const FunctionCallbackInfo& args); size_t self_size() const override { return sizeof(*this); } @@ -69,7 +68,6 @@ class FSEventWrap: public HandleWrap { int status); uv_fs_event_t handle_; - bool initialized_ = false; enum encoding encoding_ = kDefaultEncoding; }; @@ -89,7 +87,7 @@ FSEventWrap::~FSEventWrap() { void FSEventWrap::GetInitialized(const FunctionCallbackInfo& args) { FSEventWrap* wrap = Unwrap(args.This()); CHECK_NOT_NULL(wrap); - args.GetReturnValue().Set(wrap->initialized_); + args.GetReturnValue().Set(!wrap->IsHandleClosing()); } void FSEventWrap::Initialize(Local target, @@ -134,7 +132,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo& args) { FSEventWrap* wrap = Unwrap(args.This()); CHECK_NOT_NULL(wrap); - CHECK(!wrap->initialized_); + CHECK(wrap->IsHandleClosing()); // Check that Start() has not been called. const int argc = args.Length(); CHECK_GE(argc, 4); @@ -155,7 +153,6 @@ void FSEventWrap::Start(const FunctionCallbackInfo& args) { err = uv_fs_event_start(&wrap->handle_, OnEvent, *path, flags); wrap->MarkAsInitialized(); - wrap->initialized_ = true; if (err != 0) { FSEventWrap::Close(args); @@ -230,16 +227,6 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, wrap->MakeCallback(env->onchange_string(), arraysize(argv), argv); } - -void FSEventWrap::Close(const FunctionCallbackInfo& args) { - FSEventWrap* wrap = Unwrap(args.Holder()); - CHECK_NOT_NULL(wrap); - CHECK(wrap->initialized_); - - wrap->initialized_ = false; - HandleWrap::Close(args); -} - } // anonymous namespace } // namespace node