Skip to content

Commit 7ed9e5d

Browse files
addaleaxMylesBorins
authored andcommitted
src: remove StreamResourc::Cast()
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]>
1 parent 28ef3de commit 7ed9e5d

8 files changed

+2
-25
lines changed

src/js_stream.cc

-5
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ void JSStream::OnReadImpl(ssize_t nread,
7474
}
7575

7676

77-
void* JSStream::Cast() {
78-
return static_cast<void*>(this);
79-
}
80-
81-
8277
AsyncWrap* JSStream::GetAsyncWrap() {
8378
return static_cast<AsyncWrap*>(this);
8479
}

src/js_stream.h

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class JSStream : public AsyncWrap, public StreamBase {
1818

1919
~JSStream();
2020

21-
void* Cast() override;
2221
bool IsAlive() override;
2322
bool IsClosing() override;
2423
int ReadStart() override;

src/node_http2.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,7 @@ class Http2Stream : public AsyncWrap,
657657
return false;
658658
}
659659

660-
AsyncWrap* GetAsyncWrap() override { return static_cast<AsyncWrap*>(this); }
661-
void* Cast() override { return reinterpret_cast<void*>(this); }
660+
AsyncWrap* GetAsyncWrap() override { return this; }
662661

663662
int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
664663
uv_stream_t* send_handle) override;

src/stream_base.h

-4
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ class StreamBase : public StreamResource {
231231
v8::Local<v8::FunctionTemplate> target,
232232
int flags = kFlagNone);
233233

234-
virtual void* Cast() = 0;
235234
virtual bool IsAlive() = 0;
236235
virtual bool IsClosing() = 0;
237236
virtual bool IsIPCPipe();
@@ -250,9 +249,6 @@ class StreamBase : public StreamResource {
250249
consumed_ = false;
251250
}
252251

253-
template <class Outer>
254-
inline Outer* Cast() { return static_cast<Outer*>(Cast()); }
255-
256252
void EmitData(ssize_t nread,
257253
v8::Local<v8::Object> buf,
258254
v8::Local<v8::Object> handle);

src/stream_wrap.cc

-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ bool LibuvStreamWrap::IsClosing() {
126126
}
127127

128128

129-
void* LibuvStreamWrap::Cast() {
130-
return reinterpret_cast<void*>(this);
131-
}
132-
133-
134129
AsyncWrap* LibuvStreamWrap::GetAsyncWrap() {
135130
return static_cast<AsyncWrap*>(this);
136131
}

src/stream_wrap.h

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
4040
v8::Local<v8::Context> context);
4141

4242
int GetFD() override;
43-
void* Cast() override;
4443
bool IsAlive() override;
4544
bool IsClosing() override;
4645
bool IsIPCPipe() override;

src/tls_wrap.cc

+1-6
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ void TLSWrap::EncOut() {
347347

348348

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

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

536536

537-
void* TLSWrap::Cast() {
538-
return reinterpret_cast<void*>(this);
539-
}
540-
541-
542537
AsyncWrap* TLSWrap::GetAsyncWrap() {
543538
return static_cast<AsyncWrap*>(this);
544539
}

src/tls_wrap.h

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class TLSWrap : public AsyncWrap,
5656
v8::Local<v8::Value> unused,
5757
v8::Local<v8::Context> context);
5858

59-
void* Cast() override;
6059
int GetFD() override;
6160
bool IsAlive() override;
6261
bool IsClosing() override;

0 commit comments

Comments
 (0)