Skip to content

Commit bb0795a

Browse files
addaleaxtargos
authored andcommitted
src: slightly simplify FSEventWrap
We don’t need to track `initialized_`, `HandleWrap` already does that for us. PR-URL: #21533 Reviewed-By: Eugene Ostroukhov <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 41c4b2c commit bb0795a

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/fs_event_wrap.cc

+2-15
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class FSEventWrap: public HandleWrap {
5555
Local<Context> context);
5656
static void New(const FunctionCallbackInfo<Value>& args);
5757
static void Start(const FunctionCallbackInfo<Value>& args);
58-
static void Close(const FunctionCallbackInfo<Value>& args);
5958
static void GetInitialized(const FunctionCallbackInfo<Value>& args);
6059
size_t self_size() const override { return sizeof(*this); }
6160

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

7170
uv_fs_event_t handle_;
72-
bool initialized_ = false;
7371
enum encoding encoding_ = kDefaultEncoding;
7472
};
7573

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

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

135133
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
136134
CHECK_NOT_NULL(wrap);
137-
CHECK(!wrap->initialized_);
135+
CHECK(wrap->IsHandleClosing()); // Check that Start() has not been called.
138136

139137
const int argc = args.Length();
140138
CHECK_GE(argc, 4);
@@ -155,7 +153,6 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
155153

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

160157
if (err != 0) {
161158
FSEventWrap::Close(args);
@@ -230,16 +227,6 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
230227
wrap->MakeCallback(env->onchange_string(), arraysize(argv), argv);
231228
}
232229

233-
234-
void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
235-
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());
236-
CHECK_NOT_NULL(wrap);
237-
CHECK(wrap->initialized_);
238-
239-
wrap->initialized_ = false;
240-
HandleWrap::Close(args);
241-
}
242-
243230
} // anonymous namespace
244231
} // namespace node
245232

0 commit comments

Comments
 (0)