Skip to content

Commit c559884

Browse files
committed
Merge #10809: optim: mark a few classes final
40a0f9f Enable devirtualization opportunities by using the final specifier (C++11) (practicalswift) 9a1675e optim: mark a few classes final (Cory Fields) Pull request description: Using gcc's ```-Wsuggest-final-types``` and lto, I identified a few easy devirtualization wins: > wallet/wallet.h:651:7: warning: Declaring type 'struct CWallet' final would enable devirtualization of 26 calls [-Wsuggest-final-types] >coins.h:201:7: warning: Declaring type 'struct CCoinsViewCache' final would enable devirtualization of 13 calls [-Wsuggest-final-types] >txdb.h:67:7: warning: Declaring type 'struct CCoinsViewDB' final would enable devirtualization of 5 calls [-Wsuggest-final-types] >zmq/zmqnotificationinterface.h:16:7: warning: Declaring type 'struct CZMQNotificationInterface' final would enable devirtualization of 4 calls [-Wsuggest-final-types] >httpserver.cpp:42:7: warning: Declaring type 'struct HTTPWorkItem' final would enable devirtualization of 2 calls [-Wsuggest-final-types] Tree-SHA512: 2a825fd27121ccabaacff5cde2fc8a50d1b4cc846374606caa2a71b0cd8fcb0d3c9b5b3fd342d944998610e2168048601278f8a3709cc515191a0bb2d98ba782
2 parents 7ee6c43 + 40a0f9f commit c559884

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
static const size_t MAX_HEADERS_SIZE = 8192;
4141

4242
/** HTTP request work item */
43-
class HTTPWorkItem : public HTTPClosure
43+
class HTTPWorkItem final : public HTTPClosure
4444
{
4545
public:
4646
HTTPWorkItem(std::unique_ptr<HTTPRequest> _req, const std::string &_path, const HTTPRequestHandler& _func):

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ bool ShutdownRequested()
133133
* chainstate, while keeping user interface out of the common library, which is shared
134134
* between bitcoind, and bitcoin-qt and non-server tools.
135135
*/
136-
class CCoinsViewErrorCatcher : public CCoinsViewBacked
136+
class CCoinsViewErrorCatcher final : public CCoinsViewBacked
137137
{
138138
public:
139139
explicit CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {}

src/txdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct CDiskTxPos : public CDiskBlockPos
6464
};
6565

6666
/** CCoinsView backed by the coin database (chainstate/) */
67-
class CCoinsViewDB : public CCoinsView
67+
class CCoinsViewDB final : public CCoinsView
6868
{
6969
protected:
7070
CDBWrapper db;

src/wallet/wallet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class CAccountingEntry
651651
* A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,
652652
* and provides the ability to create new transactions.
653653
*/
654-
class CWallet : public CCryptoKeyStore, public CValidationInterface
654+
class CWallet final : public CCryptoKeyStore, public CValidationInterface
655655
{
656656
private:
657657
static std::atomic<bool> fFlushScheduled;
@@ -1131,7 +1131,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
11311131
};
11321132

11331133
/** A key allocated from the key pool. */
1134-
class CReserveKey : public CReserveScript
1134+
class CReserveKey final : public CReserveScript
11351135
{
11361136
protected:
11371137
CWallet* pwallet;

src/zmq/zmqnotificationinterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class CBlockIndex;
1414
class CZMQAbstractNotifier;
1515

16-
class CZMQNotificationInterface : public CValidationInterface
16+
class CZMQNotificationInterface final : public CValidationInterface
1717
{
1818
public:
1919
virtual ~CZMQNotificationInterface();

0 commit comments

Comments
 (0)