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 983cb26

Browse filesBrowse files
danbevtargos
authored andcommitted
src: don't create Undefined if not needed
This commit moves the creation of argv and only creates an undefined value if the passed in status was not 0. The variable name client_handle was already used in this function but I've change that usage so that this variable name matches the onconnection callback functions parameter name clientHandle. PR-URL: #20573 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent e01e060 commit 983cb26
Copy full SHA for 983cb26

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+8
-8
lines changed
Open diff view settings
Collapse file

‎src/connection_wrap.cc‎

Copy file name to clipboardExpand all lines: src/connection_wrap.cc
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ void ConnectionWrap<WrapType, UVType>::OnConnection(uv_stream_t* handle,
4545
// uv_close() on the handle.
4646
CHECK_EQ(wrap_data->persistent().IsEmpty(), false);
4747

48-
Local<Value> argv[] = {
49-
Integer::New(env->isolate(), status),
50-
Undefined(env->isolate())
51-
};
48+
Local<Value> client_handle;
5249

5350
if (status == 0) {
5451
// Instantiate the client javascript object and handle.
@@ -59,17 +56,20 @@ void ConnectionWrap<WrapType, UVType>::OnConnection(uv_stream_t* handle,
5956
// Unwrap the client javascript object.
6057
WrapType* wrap;
6158
ASSIGN_OR_RETURN_UNWRAP(&wrap, client_obj);
62-
uv_stream_t* client_handle =
63-
reinterpret_cast<uv_stream_t*>(&wrap->handle_);
59+
uv_stream_t* client = reinterpret_cast<uv_stream_t*>(&wrap->handle_);
6460
// uv_accept can fail if the new connection has already been closed, in
6561
// which case an EAGAIN (resource temporarily unavailable) will be
6662
// returned.
67-
if (uv_accept(handle, client_handle))
63+
if (uv_accept(handle, client))
6864
return;
6965

7066
// Successful accept. Call the onconnection callback in JavaScript land.
71-
argv[1] = client_obj;
67+
client_handle = client_obj;
68+
} else {
69+
client_handle = Undefined(env->isolate());
7270
}
71+
72+
Local<Value> argv[] = { Integer::New(env->isolate(), status), client_handle };
7373
wrap_data->MakeCallback(env->onconnection_string(), arraysize(argv), argv);
7474
}
7575

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.