src: slightly simplify FSEventWrap

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 <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>
This commit is contained in:
Anna Henningsen authored and James M Snell committed 2018-06-29 12:02:46 -07:00
1 parent f5db04dcbd
commit bf360d2e15
1 file changed
+2 -15
+2 -15
View File
@@ -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); }
@@ -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<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,
@@ -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);
@@ -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);
@@ -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