Skip to content

Commit

Permalink
Make inherited classes final if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Jul 4, 2021
1 parent edfa5d1 commit 40c5d47
Show file tree
Hide file tree
Showing 197 changed files with 862 additions and 862 deletions.
12 changes: 6 additions & 6 deletions benchmark/bench_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#endif

template <int type>
class RingBench : public td::Benchmark {
class RingBench final : public td::Benchmark {
public:
struct PassActor;

Expand All @@ -37,7 +37,7 @@ class RingBench : public td::Benchmark {
return PSTRING() << "Ring (send_" << types[type] << ") (threads_n = " << thread_n_ << ")";
}

struct PassActor : public td::Actor {
struct PassActor final : public td::Actor {
int id = -1;
td::ActorId<PassActor> next_actor;
int start_n = 0;
Expand Down Expand Up @@ -118,15 +118,15 @@ class RingBench : public td::Benchmark {
};

template <int type>
class QueryBench : public td::Benchmark {
class QueryBench final : public td::Benchmark {
public:
std::string get_description() const final {
static const char *types[] = {"callback", "immediate future", "delayed future", "dummy", "lambda", "lambda_future"};
static_assert(0 <= type && type < 6, "");
return PSTRING() << "QueryBench: " << types[type];
}

class ClientActor : public td::Actor {
class ClientActor final : public td::Actor {
public:
class Callback {
public:
Expand Down Expand Up @@ -157,9 +157,9 @@ class QueryBench : public td::Benchmark {
td::unique_ptr<Callback> callback_;
};

class ServerActor : public td::Actor {
class ServerActor final : public td::Actor {
public:
class ClientCallback : public ClientActor::Callback {
class ClientCallback final : public ClientActor::Callback {
public:
explicit ClientCallback(td::ActorId<ServerActor> server) : server_(server) {
}
Expand Down
22 changes: 11 additions & 11 deletions benchmark/bench_crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static constexpr int DATA_SIZE = 8 << 10;
static constexpr int SHORT_DATA_SIZE = 64;

#if OPENSSL_VERSION_NUMBER <= 0x10100000L
class SHA1Bench : public td::Benchmark {
class SHA1Bench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];

Expand All @@ -53,7 +53,7 @@ class SHA1Bench : public td::Benchmark {
};
#endif

class AesEcbBench : public td::Benchmark {
class AesEcbBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -84,7 +84,7 @@ class AesEcbBench : public td::Benchmark {
}
};

class AesIgeEncryptBench : public td::Benchmark {
class AesIgeEncryptBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -112,7 +112,7 @@ class AesIgeEncryptBench : public td::Benchmark {
}
};

class AesIgeDecryptBench : public td::Benchmark {
class AesIgeDecryptBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -140,7 +140,7 @@ class AesIgeDecryptBench : public td::Benchmark {
}
};

class AesCtrBench : public td::Benchmark {
class AesCtrBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -169,7 +169,7 @@ class AesCtrBench : public td::Benchmark {
};

#if OPENSSL_VERSION_NUMBER >= 0x10100000L
class AesCtrOpenSSLBench : public td::Benchmark {
class AesCtrOpenSSLBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -205,7 +205,7 @@ class AesCtrOpenSSLBench : public td::Benchmark {
};
#endif

class AesCbcDecryptBench : public td::Benchmark {
class AesCbcDecryptBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand All @@ -231,7 +231,7 @@ class AesCbcDecryptBench : public td::Benchmark {
}
};

class AesCbcEncryptBench : public td::Benchmark {
class AesCbcEncryptBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];
td::UInt256 key;
Expand All @@ -258,7 +258,7 @@ class AesCbcEncryptBench : public td::Benchmark {
};

template <bool use_state>
class AesIgeShortBench : public td::Benchmark {
class AesIgeShortBench final : public td::Benchmark {
public:
alignas(64) unsigned char data[SHORT_DATA_SIZE];
td::UInt256 key;
Expand Down Expand Up @@ -363,7 +363,7 @@ BENCH(Pbkdf2, "pbkdf2") {
td::pbkdf2_sha256(password, salt, n, key);
}

class Crc32Bench : public td::Benchmark {
class Crc32Bench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];

Expand All @@ -387,7 +387,7 @@ class Crc32Bench : public td::Benchmark {
}
};

class Crc64Bench : public td::Benchmark {
class Crc64Bench final : public td::Benchmark {
public:
alignas(64) unsigned char data[DATA_SIZE];

Expand Down
14 changes: 7 additions & 7 deletions benchmark/bench_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <memory>

template <class KeyValueT>
class TdKvBench : public td::Benchmark {
class TdKvBench final : public td::Benchmark {
td::ConcurrentScheduler sched;
td::string name_;

Expand All @@ -41,7 +41,7 @@ class TdKvBench : public td::Benchmark {
return name_;
}

class Main : public td::Actor {
class Main final : public td::Actor {
public:
explicit Main(int n) : n_(n) {
}
Expand All @@ -50,7 +50,7 @@ class TdKvBench : public td::Benchmark {
void loop() final {
KeyValueT::destroy("test_tddb").ignore();

class Worker : public Actor {
class Worker final : public Actor {
public:
Worker(int n, td::string db_name) : n_(n) {
kv_.init(db_name).ensure();
Expand Down Expand Up @@ -89,7 +89,7 @@ class TdKvBench : public td::Benchmark {
};

template <bool is_encrypted = false>
class SqliteKVBench : public td::Benchmark {
class SqliteKVBench final : public td::Benchmark {
td::SqliteDb db;
td::string get_description() const final {
return PSTRING() << "SqliteKV " << td::tag("is_encrypted", is_encrypted);
Expand Down Expand Up @@ -142,7 +142,7 @@ static td::Status init_db(td::SqliteDb &db) {
return td::Status::OK();
}

class SqliteKeyValueAsyncBench : public td::Benchmark {
class SqliteKeyValueAsyncBench final : public td::Benchmark {
public:
td::string get_description() const final {
return "SqliteKeyValueAsync";
Expand Down Expand Up @@ -199,7 +199,7 @@ class SqliteKeyValueAsyncBench : public td::Benchmark {
}
};

class SeqKvBench : public td::Benchmark {
class SeqKvBench final : public td::Benchmark {
td::string get_description() const final {
return "SeqKvBench";
}
Expand All @@ -213,7 +213,7 @@ class SeqKvBench : public td::Benchmark {
};

template <bool is_encrypted = false>
class BinlogKeyValueBench : public td::Benchmark {
class BinlogKeyValueBench final : public td::Benchmark {
td::string get_description() const final {
return PSTRING() << "BinlogKeyValue " << td::tag("is_encrypted", is_encrypted);
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ static string prime_base64 =
"WC2xF40WnGvEZbDW_5yjko_vW5rk5Bj8Feg-vqD4f6n_Xu1wBQ3tKEn0e_lZ2VaFDOkphR8NgRX2NbEF7i5OFdBLJFS_b0-t8DSxBAMRnNjjuS_MW"
"w";

class HandshakeBench : public Benchmark {
class HandshakeBench final : public Benchmark {
std::string get_description() const final {
return "Handshake";
}

class FakeDhCallback : public DhCallback {
class FakeDhCallback final : public DhCallback {
public:
int is_good_prime(Slice prime_str) const final {
auto it = cache.find(prime_str.str());
Expand Down
2 changes: 1 addition & 1 deletion benchmark/bench_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace td {

std::atomic<int> counter;

class HttpClient : public HttpOutboundConnection::Callback {
class HttpClient final : public HttpOutboundConnection::Callback {
void start_up() final {
IPAddress addr;
addr.init_ipv4_port("127.0.0.1", 8082).ensure();
Expand Down
6 changes: 3 additions & 3 deletions benchmark/bench_http_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
static std::string http_query = "GET / HTTP/1.1\r\nConnection:keep-alive\r\nhost:127.0.0.1:8080\r\n\r\n";
static const size_t block_size = 2500;

class HttpReaderBench : public td::Benchmark {
class HttpReaderBench final : public td::Benchmark {
std::string get_description() const final {
return "HttpReaderBench";
}
Expand Down Expand Up @@ -52,7 +52,7 @@ class HttpReaderBench : public td::Benchmark {
}
};

class BufferBench : public td::Benchmark {
class BufferBench final : public td::Benchmark {
std::string get_description() const final {
return "BufferBench";
}
Expand All @@ -78,7 +78,7 @@ class BufferBench : public td::Benchmark {
}
};

class FindBoundaryBench : public td::Benchmark {
class FindBoundaryBench final : public td::Benchmark {
std::string get_description() const final {
return "FindBoundaryBench";
}
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace td {

static int cnt = 0;

class HelloWorld : public HttpInboundConnection::Callback {
class HelloWorld final : public HttpInboundConnection::Callback {
public:
void handle(unique_ptr<HttpQuery> query, ActorOwn<HttpInboundConnection> connection) final {
// LOG(ERROR) << *query;
Expand All @@ -47,7 +47,7 @@ class HelloWorld : public HttpInboundConnection::Callback {
};

const int N = 0;
class Server : public TcpListener::Callback {
class Server final : public TcpListener::Callback {
public:
void start_up() final {
listener_ = create_actor<TcpListener>("Listener", 8082, ActorOwn<TcpListener::Callback>(actor_id(this)));
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_http_server_cheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace td {

// HttpInboundConnection header
static int cnt = 0;
class HelloWorld : public Actor {
class HelloWorld final : public Actor {
public:
explicit HelloWorld(SocketFd socket_fd) : socket_fd_(std::move(socket_fd)) {
}
Expand Down Expand Up @@ -98,7 +98,7 @@ class HelloWorld : public Actor {
}
};
const int N = 0;
class Server : public TcpListener::Callback {
class Server final : public TcpListener::Callback {
public:
void start_up() final {
listener_ = create_actor<TcpListener>("Listener", 8082, ActorOwn<TcpListener::Callback>(actor_id(this)));
Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_http_server_fast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace td {

class HttpEchoConnection : public Actor {
class HttpEchoConnection final : public Actor {
public:
explicit HttpEchoConnection(SocketFd fd) : fd_(std::move(fd)) {
}
Expand Down Expand Up @@ -85,7 +85,7 @@ class HttpEchoConnection : public Actor {
};

const int N = 8;
class Server : public TcpListener::Callback {
class Server final : public TcpListener::Callback {
public:
void start_up() final {
listener_ = create_actor<TcpListener>("Listener", 8082, ActorOwn<TcpListener::Callback>(actor_id(this)));
Expand Down
8 changes: 4 additions & 4 deletions benchmark/bench_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::string create_tmp_file() {
#endif
}

class IostreamWriteBench : public td::Benchmark {
class IostreamWriteBench final : public td::Benchmark {
protected:
std::string file_name_;
std::ofstream stream;
Expand Down Expand Up @@ -67,7 +67,7 @@ class IostreamWriteBench : public td::Benchmark {
}
};

class FILEWriteBench : public td::Benchmark {
class FILEWriteBench final : public td::Benchmark {
protected:
std::string file_name_;
FILE *file;
Expand Down Expand Up @@ -101,7 +101,7 @@ class FILEWriteBench : public td::Benchmark {
#if TD_ANDROID
#include <android/log.h>
#define ALOG(...) __android_log_print(ANDROID_LOG_VERBOSE, "XXX", __VA_ARGS__)
class ALogWriteBench : public td::Benchmark {
class ALogWriteBench final : public td::Benchmark {
public:
std::string get_description() const final {
return "android_log";
Expand All @@ -118,7 +118,7 @@ class ALogWriteBench : public td::Benchmark {
};
#endif

class LogWriteBench : public td::Benchmark {
class LogWriteBench final : public td::Benchmark {
protected:
std::string file_name_;
std::ofstream stream;
Expand Down
Loading

0 comments on commit 40c5d47

Please sign in to comment.