optim: mark a few classes final #10809

pull theuni wants to merge 2 commits into bitcoin:master from theuni:final-classes changing 5 files +6 −6
  1. theuni commented at 8:52 PM on July 12, 2017: member

    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]

  2. meshcollider commented at 9:28 PM on July 12, 2017: contributor

    test/coins_tests.cpp:74:7: error: cannot derive from ‘final’ base ‘CCoinsViewCache’ in derived type ‘{anonymous}::CCoinsViewCacheTest’ class CCoinsViewCacheTest : public CCoinsViewCache

  3. sipa commented at 9:39 PM on July 12, 2017: member

    test/coins_tests.cpp:74:7: error: cannot derive from ‘final’ base ‘CCoinsViewCache’ in derived type ‘{anonymous}::CCoinsViewCacheTest’ class CCoinsViewCacheTest : public CCoinsViewCache

    You can fix that by renaming the existing CCoinsViewCache to a non-final CCoinsViewCacheBase, and have CCoinsViewCache become a final subclass of that with no implementation except a constructor. Then CCoinsViewCacheTest can become another subclass of CCoinsViewCacheBase.

  4. meshcollider cross-referenced this on Jul 13, 2017 from issue Make CCoinsViewCache a final subclass of CCoinsViewCacheBase by meshcollider
  5. sipa cross-referenced this on Jul 16, 2017 from issue Enable devirtualization opportunities by using the final specifier (C++11) by practicalswift
  6. fanquake added the label Refactoring on Jul 17, 2017
  7. practicalswift commented at 7:56 AM on July 17, 2017: contributor

    @theuni Two more devirtualization opportunities (from closed PR #10847):

    • Declaring CCoinsViewErrorCatcher final enables devirtualization of two calls
    • Declaring CReserveKey final enables devirtualization of one call
  8. theuni commented at 1:32 PM on July 17, 2017: member

    @practicalswift I'll pull in the other two, but I think we should drop the CCoinsViewCache one. The inheritance there is hard enough to follow already.

  9. practicalswift commented at 1:34 PM on July 17, 2017: contributor

    @theuni Sounds great! :-)

  10. optim: mark a few classes final 9a1675ee5b
  11. 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
    40a0f9fb96
  12. theuni force-pushed on Jul 17, 2017
  13. gmaxwell approved
  14. gmaxwell commented at 5:25 PM on July 18, 2017: contributor

    utACK

  15. dcousens approved
  16. practicalswift commented at 3:10 AM on July 19, 2017: contributor

    utACK 40a0f9fb967a4c7e74d3a6fd4d05744af40fac68

  17. TheBlueMatt commented at 9:14 PM on July 19, 2017: contributor

    utACK 40a0f9fb967a4c7e74d3a6fd4d05744af40fac68

  18. kallewoof approved
  19. paveljanik commented at 4:27 PM on August 10, 2017: contributor

    utACK 40a0f9f

  20. laanwj merged this on Aug 21, 2017
  21. laanwj closed this on Aug 21, 2017

  22. laanwj referenced this in commit c559884cac on Aug 21, 2017
  23. PastaPastaPasta referenced this in commit 23bfd043bb on Sep 19, 2019
  24. PastaPastaPasta referenced this in commit f5cf931add on Sep 23, 2019
  25. PastaPastaPasta referenced this in commit 2bacef6872 on Sep 24, 2019
  26. PastaPastaPasta referenced this in commit e80c17217b on Nov 19, 2019
  27. PastaPastaPasta referenced this in commit b903f558b3 on Nov 21, 2019
  28. PastaPastaPasta referenced this in commit b0a3d230e7 on Dec 9, 2019
  29. PastaPastaPasta referenced this in commit c6162845d3 on Jan 1, 2020
  30. PastaPastaPasta referenced this in commit 63f6041232 on Jan 2, 2020
  31. PastaPastaPasta referenced this in commit 3646b537f4 on Jan 2, 2020
  32. PastaPastaPasta referenced this in commit 728a254023 on Jan 2, 2020
  33. PastaPastaPasta referenced this in commit 0ee32a7205 on Jan 2, 2020
  34. PastaPastaPasta referenced this in commit 62b2f3a317 on Jan 3, 2020
  35. ckti referenced this in commit 517219126b on Mar 28, 2021
  36. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC