Skip to content

Commit

Permalink
src: remove StreamResourc::Cast()
Browse files Browse the repository at this point in the history
This is not necessary since C++ already has `static_cast`
as a proper way to cast inside a class hierarchy.

PR-URL: #17564
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Jan 8, 2018
1 parent 28ef3de commit 7ed9e5d
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 25 deletions.
5 changes: 0 additions & 5 deletions src/js_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ void JSStream::OnReadImpl(ssize_t nread,
}


void* JSStream::Cast() {
return static_cast<void*>(this);
}


AsyncWrap* JSStream::GetAsyncWrap() {
return static_cast<AsyncWrap*>(this);
}
Expand Down
1 change: 0 additions & 1 deletion src/js_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class JSStream : public AsyncWrap, public StreamBase {

~JSStream();

void* Cast() override;
bool IsAlive() override;
bool IsClosing() override;
int ReadStart() override;
Expand Down
3 changes: 1 addition & 2 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,7 @@ class Http2Stream : public AsyncWrap,
return false;
}

AsyncWrap* GetAsyncWrap() override { return static_cast<AsyncWrap*>(this); }
void* Cast() override { return reinterpret_cast<void*>(this); }
AsyncWrap* GetAsyncWrap() override { return this; }

int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
uv_stream_t* send_handle) override;
Expand Down
4 changes: 0 additions & 4 deletions src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ class StreamBase : public StreamResource {
v8::Local<v8::FunctionTemplate> target,
int flags = kFlagNone);

virtual void* Cast() = 0;
virtual bool IsAlive() = 0;
virtual bool IsClosing() = 0;
virtual bool IsIPCPipe();
Expand All @@ -250,9 +249,6 @@ class StreamBase : public StreamResource {
consumed_ = false;
}

template <class Outer>
inline Outer* Cast() { return static_cast<Outer*>(Cast()); }

void EmitData(ssize_t nread,
v8::Local<v8::Object> buf,
v8::Local<v8::Object> handle);
Expand Down
5 changes: 0 additions & 5 deletions src/stream_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,6 @@ bool LibuvStreamWrap::IsClosing() {
}


void* LibuvStreamWrap::Cast() {
return reinterpret_cast<void*>(this);
}


AsyncWrap* LibuvStreamWrap::GetAsyncWrap() {
return static_cast<AsyncWrap*>(this);
}
Expand Down
1 change: 0 additions & 1 deletion src/stream_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
v8::Local<v8::Context> context);

int GetFD() override;
void* Cast() override;
bool IsAlive() override;
bool IsClosing() override;
bool IsIPCPipe() override;
Expand Down
7 changes: 1 addition & 6 deletions src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void TLSWrap::EncOut() {


void TLSWrap::EncOutCb(WriteWrap* req_wrap, int status) {
TLSWrap* wrap = req_wrap->wrap()->Cast<TLSWrap>();
TLSWrap* wrap = static_cast<TLSWrap*>(req_wrap->wrap());
req_wrap->Dispose();

// We should not be getting here after `DestroySSL`, because all queued writes
Expand Down Expand Up @@ -534,11 +534,6 @@ bool TLSWrap::ClearIn() {
}


void* TLSWrap::Cast() {
return reinterpret_cast<void*>(this);
}


AsyncWrap* TLSWrap::GetAsyncWrap() {
return static_cast<AsyncWrap*>(this);
}
Expand Down
1 change: 0 additions & 1 deletion src/tls_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class TLSWrap : public AsyncWrap,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context);

void* Cast() override;
int GetFD() override;
bool IsAlive() override;
bool IsClosing() override;
Expand Down

0 comments on commit 7ed9e5d

Please sign in to comment.