Skip to content

Commit

Permalink
src: remove unnecessary helper function
Browse files Browse the repository at this point in the history
Ever since e2fcfea, `OnReadCommon()` is no longer shared
between more than one function.

PR-URL: #14959
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mscdex authored and MylesBorins committed Sep 20, 2017
1 parent 70e9a6e commit 968121b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
30 changes: 10 additions & 20 deletions src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,18 @@ void StreamWrap::OnReadImpl(ssize_t nread,
}


void StreamWrap::OnReadCommon(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf,
uv_handle_type pending) {
void StreamWrap::OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf) {
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
HandleScope scope(wrap->env()->isolate());
Context::Scope context_scope(wrap->env()->context());
uv_handle_type type = UV_UNKNOWN_HANDLE;

if (wrap->is_named_pipe_ipc() &&
uv_pipe_pending_count(reinterpret_cast<uv_pipe_t*>(handle)) > 0) {
type = uv_pipe_pending_type(reinterpret_cast<uv_pipe_t*>(handle));
}

// We should not be getting this callback if someone as already called
// uv_close() on the handle.
Expand All @@ -242,22 +247,7 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle,
}
}

static_cast<StreamBase*>(wrap)->OnRead(nread, buf, pending);
}


void StreamWrap::OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf) {
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
uv_handle_type type = UV_UNKNOWN_HANDLE;

if (wrap->is_named_pipe_ipc() &&
uv_pipe_pending_count(reinterpret_cast<uv_pipe_t*>(handle)) > 0) {
type = uv_pipe_pending_type(reinterpret_cast<uv_pipe_t*>(handle));
}

OnReadCommon(handle, nread, buf, type);
static_cast<StreamBase*>(wrap)->OnRead(nread, buf, type);
}


Expand Down
4 changes: 0 additions & 4 deletions src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ class StreamWrap : public HandleWrap, public StreamBase {
static void OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf);
static void OnReadCommon(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf,
uv_handle_type pending);
static void AfterWrite(uv_write_t* req, int status);
static void AfterShutdown(uv_shutdown_t* req, int status);

Expand Down

0 comments on commit 968121b

Please sign in to comment.