Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb0795a

Browse filesBrowse 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 <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>
1 parent 41c4b2c commit bb0795a
Copy full SHA for bb0795a

File tree

Expand file treeCollapse file tree

1 file changed

+2
-15
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-15
lines changed
Open diff view settings
Collapse file

‎src/fs_event_wrap.cc‎

Copy file name to clipboardExpand all lines: src/fs_event_wrap.cc
+2-15Lines changed: 2 additions & 15 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.