Skip to content

Commit

Permalink
src: slightly simplify FSEventWrap
Browse files Browse the repository at this point in the history
We don’t need to track `initialized_`, `HandleWrap` already does
that for us.

PR-URL: #21533
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and targos committed Jun 29, 2018
1 parent 41c4b2c commit bb0795a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/fs_event_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class FSEventWrap: public HandleWrap {
Local<Context> context);
static void New(const FunctionCallbackInfo<Value>& args);
static void Start(const FunctionCallbackInfo<Value>& args);
static void Close(const FunctionCallbackInfo<Value>& args);
static void GetInitialized(const FunctionCallbackInfo<Value>& args);
size_t self_size() const override { return sizeof(*this); }

Expand All @@ -69,7 +68,6 @@ class FSEventWrap: public HandleWrap {
int status);

uv_fs_event_t handle_;
bool initialized_ = false;
enum encoding encoding_ = kDefaultEncoding;
};

Expand All @@ -89,7 +87,7 @@ FSEventWrap::~FSEventWrap() {
void FSEventWrap::GetInitialized(const FunctionCallbackInfo<Value>& args) {
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
CHECK_NOT_NULL(wrap);
args.GetReturnValue().Set(wrap->initialized_);
args.GetReturnValue().Set(!wrap->IsHandleClosing());
}

void FSEventWrap::Initialize(Local<Object> target,
Expand Down Expand Up @@ -134,7 +132,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {

FSEventWrap* wrap = Unwrap<FSEventWrap>(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);
Expand All @@ -155,7 +153,6 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {

err = uv_fs_event_start(&wrap->handle_, OnEvent, *path, flags);
wrap->MarkAsInitialized();
wrap->initialized_ = true;

if (err != 0) {
FSEventWrap::Close(args);
Expand Down Expand Up @@ -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<Value>& args) {
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());
CHECK_NOT_NULL(wrap);
CHECK(wrap->initialized_);

wrap->initialized_ = false;
HandleWrap::Close(args);
}

} // anonymous namespace
} // namespace node

Expand Down

0 comments on commit bb0795a

Please sign in to comment.