Skip to content

Dead code elimination 2

SlowRiot requested to merge SlowRiot/bitcoin-cash-node:dead_code2 into master

There is some dead code in the codebase (#425). See the issue and !1545 for more background.

  • Some functions are never called at all.
  • Some functions are called only in their own tests, taking up precious test time but providing no useful functionality.
  • Some functions are called only on certain platforms, but are compiled on all platforms.
  • Some functions are needed in tests but never called outside them, yet are still compiled as part of the non-test binaries.

By eliminating dead code, and limiting compilation of occasionally-live code only to targets where it is needed, there are improvements to be had - code size decreases and maintainability improves, binary sizes decrease a little, compilation takes a little less time, and tests run a little faster.

Changes

This is one of a sequence of MRs, each kept relatively small to ease review effort. This is in parallel with !1545, but not on top of it, so the diffs do not overlap, and it is ready for review immediately.

The following functions were never called in the code, and have been removed outright:

  • BlockFilter unused constructor
  • Three GetVirtualTransactionSize overloads
    • surrounding definitions simplified
  • QValueComboBox::setRole
  • ParseHex0() unused overload (other overloads are used)
  • InferDescriptor()
  • One unused explicit instantiation of the PrecomputedTransactionData template
  • TXMempool:
    • CTxMemPoolEntry::UpdateLockPoints() function and update_lock_points functor
    • CTxMemPool::GetConflictTx()
    • CTxMemPool::HasNoInputsOf()
  • reset() in CBloomFilter

Omissions and out-of-scope

This MR is only a subset of unused code to be removed, future MRs will be raised for other portions to ease review effort. See !1545 for more detail.

Test plan

ninja all ninja check-all

Verify there are no compilation errors or warnings, and all tests pass.

Edited by SlowRiot

Merge request reports