From 9a1675ee5b27f8634f9917a1f80904c9319739d3 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Wed, 12 Jul 2017 16:48:36 -0400 Subject: [PATCH 1/2] optim: mark a few classes final --- src/httpserver.cpp | 2 +- src/txdb.h | 2 +- src/wallet/wallet.h | 2 +- src/zmq/zmqnotificationinterface.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 290a2efca..f37b28f71 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -40,7 +40,7 @@ static const size_t MAX_HEADERS_SIZE = 8192; /** HTTP request work item */ -class HTTPWorkItem : public HTTPClosure +class HTTPWorkItem final : public HTTPClosure { public: HTTPWorkItem(std::unique_ptr _req, const std::string &_path, const HTTPRequestHandler& _func): diff --git a/src/txdb.h b/src/txdb.h index adcbc7338..385e3ea91 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -64,7 +64,7 @@ struct CDiskTxPos : public CDiskBlockPos }; /** CCoinsView backed by the coin database (chainstate/) */ -class CCoinsViewDB : public CCoinsView +class CCoinsViewDB final : public CCoinsView { protected: CDBWrapper db; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 06937566b..9901f5f8c 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -648,7 +648,7 @@ private: * A CWallet is an extension of a keystore, which also maintains a set of transactions and balances, * and provides the ability to create new transactions. */ -class CWallet : public CCryptoKeyStore, public CValidationInterface +class CWallet final : public CCryptoKeyStore, public CValidationInterface { private: static std::atomic fFlushScheduled; diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h index eec6f7bc6..cb92216fa 100644 --- a/src/zmq/zmqnotificationinterface.h +++ b/src/zmq/zmqnotificationinterface.h @@ -13,7 +13,7 @@ class CBlockIndex; class CZMQAbstractNotifier; -class CZMQNotificationInterface : public CValidationInterface +class CZMQNotificationInterface final : public CValidationInterface { public: virtual ~CZMQNotificationInterface(); From 40a0f9fb967a4c7e74d3a6fd4d05744af40fac68 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 16 Jul 2017 23:42:27 +0200 Subject: [PATCH 2/2] Enable devirtualization opportunities by using the final specifier (C++11) * Declaring CCoinsViewErrorCatcher final enables devirtualization of two calls * Declaring CReserveKey final enables devirtualization of one call --- src/init.cpp | 2 +- src/wallet/wallet.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index d9b98be73..b64d303bd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -133,7 +133,7 @@ bool ShutdownRequested() * chainstate, while keeping user interface out of the common library, which is shared * between bitcoind, and bitcoin-qt and non-server tools. */ -class CCoinsViewErrorCatcher : public CCoinsViewBacked +class CCoinsViewErrorCatcher final : public CCoinsViewBacked { public: CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {} diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9901f5f8c..11ea89dc6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1135,7 +1135,7 @@ public: }; /** A key allocated from the key pool. */ -class CReserveKey : public CReserveScript +class CReserveKey final : public CReserveScript { protected: CWallet* pwallet;