Skip to content

Commit

Permalink
Merge bitcoin#10809: optim: mark a few classes final
Browse files Browse the repository at this point in the history
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
  • Loading branch information
laanwj authored and PastaPastaPasta committed Jan 2, 2020
1 parent c1d6a7f commit 3646b53
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/httpserver.cpp
Expand Up @@ -45,7 +45,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<HTTPRequest> _req, const std::string &_path, const HTTPRequestHandler& _func):
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Expand Up @@ -170,7 +170,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) {}
Expand Down
2 changes: 1 addition & 1 deletion src/txdb.h
Expand Up @@ -65,7 +65,7 @@ struct CDiskTxPos : public CDiskBlockPos
};

/** CCoinsView backed by the coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView
class CCoinsViewDB final : public CCoinsView
{
protected:
CDBWrapper db;
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.h
Expand Up @@ -702,7 +702,7 @@ class CAccountingEntry
* 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<bool> fFlushScheduled;
Expand Down Expand Up @@ -1260,7 +1260,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
};

/** A key allocated from the key pool. */
class CReserveKey : public CReserveScript
class CReserveKey final : public CReserveScript
{
protected:
CWallet* pwallet;
Expand Down
2 changes: 1 addition & 1 deletion src/zmq/zmqnotificationinterface.h
Expand Up @@ -13,7 +13,7 @@
class CBlockIndex;
class CZMQAbstractNotifier;

class CZMQNotificationInterface : public CValidationInterface
class CZMQNotificationInterface final : public CValidationInterface
{
public:
virtual ~CZMQNotificationInterface();
Expand Down

0 comments on commit 3646b53

Please sign in to comment.