Skip to content

Commit

Permalink
Use final keyword for devirtualization (yhirose#1779)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-park authored Feb 17, 2024
1 parent ad40bd6 commit c5a0673
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ class DataSink {
std::ostream os;

private:
class data_sink_streambuf : public std::streambuf {
class data_sink_streambuf final : public std::streambuf {
public:
explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}

Expand Down Expand Up @@ -663,7 +663,7 @@ class TaskQueue {
virtual void on_idle() {}
};

class ThreadPool : public TaskQueue {
class ThreadPool final : public TaskQueue {
public:
explicit ThreadPool(size_t n, size_t mqr = 0)
: shutdown_(false), max_queued_requests_(mqr) {
Expand Down Expand Up @@ -780,7 +780,7 @@ class MatcherBase {
* the resulting capture will be
* {{"capture", "1"}, {"second_capture", "2"}}
*/
class PathParamsMatcher : public MatcherBase {
class PathParamsMatcher final : public MatcherBase {
public:
PathParamsMatcher(const std::string &pattern);

Expand Down Expand Up @@ -810,7 +810,7 @@ class PathParamsMatcher : public MatcherBase {
* This means that wildcard patterns may match multiple path segments with /:
* "/begin/(.*)/end" will match both "/begin/middle/end" and "/begin/1/2/end".
*/
class RegexMatcher : public MatcherBase {
class RegexMatcher final : public MatcherBase {
public:
RegexMatcher(const std::string &pattern) : regex_(pattern) {}

Expand Down Expand Up @@ -1737,7 +1737,7 @@ class SSLServer : public Server {
std::mutex ctx_mutex_;
};

class SSLClient : public ClientImpl {
class SSLClient final : public ClientImpl {
public:
explicit SSLClient(const std::string &host);

Expand Down Expand Up @@ -2126,7 +2126,7 @@ enum class EncodingType { None = 0, Gzip, Brotli };

EncodingType encoding_type(const Request &req, const Response &res);

class BufferStream : public Stream {
class BufferStream final : public Stream {
public:
BufferStream() = default;
~BufferStream() override = default;
Expand Down Expand Up @@ -2166,7 +2166,7 @@ class decompressor {
Callback callback) = 0;
};

class nocompressor : public compressor {
class nocompressor final : public compressor {
public:
~nocompressor() override = default;

Expand All @@ -2175,7 +2175,7 @@ class nocompressor : public compressor {
};

#ifdef CPPHTTPLIB_ZLIB_SUPPORT
class gzip_compressor : public compressor {
class gzip_compressor final : public compressor {
public:
gzip_compressor();
~gzip_compressor() override;
Expand All @@ -2188,7 +2188,7 @@ class gzip_compressor : public compressor {
z_stream strm_;
};

class gzip_decompressor : public decompressor {
class gzip_decompressor final : public decompressor {
public:
gzip_decompressor();
~gzip_decompressor() override;
Expand All @@ -2205,7 +2205,7 @@ class gzip_decompressor : public decompressor {
#endif

#ifdef CPPHTTPLIB_BROTLI_SUPPORT
class brotli_compressor : public compressor {
class brotli_compressor final : public compressor {
public:
brotli_compressor();
~brotli_compressor();
Expand All @@ -2217,7 +2217,7 @@ class brotli_compressor : public compressor {
BrotliEncoderState *state_ = nullptr;
};

class brotli_decompressor : public decompressor {
class brotli_decompressor final : public decompressor {
public:
brotli_decompressor();
~brotli_decompressor();
Expand Down Expand Up @@ -2935,7 +2935,7 @@ inline bool is_socket_alive(socket_t sock) {
return detail::read_socket(sock, &buf[0], sizeof(buf), MSG_PEEK) > 0;
}

class SocketStream : public Stream {
class SocketStream final : public Stream {
public:
SocketStream(socket_t sock, time_t read_timeout_sec, time_t read_timeout_usec,
time_t write_timeout_sec, time_t write_timeout_usec);
Expand Down Expand Up @@ -2964,7 +2964,7 @@ class SocketStream : public Stream {
};

#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
class SSLSocketStream : public Stream {
class SSLSocketStream final : public Stream {
public:
SSLSocketStream(socket_t sock, SSL *ssl, time_t read_timeout_sec,
time_t read_timeout_usec, time_t write_timeout_sec,
Expand Down

0 comments on commit c5a0673

Please sign in to comment.