Merge #16092: Don't use global (external) symbols for symbols that are used in only one translation unit
0959d37e3e
Don't use global (external) symbols for symbols that are used in only one translation unit (practicalswift) Pull request description: Don't use global (external) symbols for symbols that are used in only one translation unit. Before: ``` $ for SYMBOL in $(nm src/bitcoind | grep -E ' [BD] ' | c++filt | cut -f3- -d' ' | grep -v @ | grep -v : | sort | grep '[a-z]' | sort -u | grep -vE '(^_|typeinfo|vtable)'); do REFERENCES=$(git grep -lE "([^a-zA-Z]|^)${SYMBOL}([^a-zA-Z]|\$)" -- "*.cpp" "*.h") N_REFERENCES=$(wc -l <<< "${REFERENCES}") if [[ ${N_REFERENCES} > 1 ]]; then continue fi echo "Global symbol ${SYMBOL} is used in only one translation unit: ${REFERENCES}" done Global symbol g_chainstate is used in only one translation unit: src/validation.cpp Global symbol g_ui_signals is used in only one translation unit: src/ui_interface.cpp Global symbol instance_of_cmaincleanup is used in only one translation unit: src/validation.cpp Global symbol instance_of_cnetcleanup is used in only one translation unit: src/net.cpp Global symbol instance_of_cnetprocessingcleanup is used in only one translation unit: src/net_processing.cpp Global symbol pindexBestForkBase is used in only one translation unit: src/validation.cpp Global symbol pindexBestForkTip is used in only one translation unit: src/validation.cpp $ ``` After: ``` $ for SYMBOL in $(nm src/bitcoind | grep -E ' [BD] ' | c++filt | cut -f3- -d' ' | grep -v @ | grep -v : | sort | grep '[a-z]' | sort -u | grep -vE '(^_|typeinfo|vtable)'); do REFERENCES=$(git grep -lE "([^a-zA-Z]|^)${SYMBOL}([^a-zA-Z]|\$)" -- "*.cpp" "*.h") N_REFERENCES=$(wc -l <<< "${REFERENCES}") if [[ ${N_REFERENCES} > 1 ]]; then continue fi echo "Global symbol ${SYMBOL} is used in only one translation unit: ${REFERENCES}" done $ ``` ♻️ Think about future generations: save the global namespace from unnecessary pollution! ♻️ ACKs for commit 0959d3: Empact: ACK0959d37e3e
MarcoFalke: ACK0959d37e3e
hebasto: ACK0959d37e3e
promag: ACK0959d37
. Tree-SHA512: 722f66bb50450f19b57e8a8fbe949f30cd651eb8564e5787cbb772a539bf3a288c048dc49e655fd73ece6a46f6dafade515ec4004729bf2b3ab83117b7c5d153
This commit is contained in:
commit
0b68fca700
4 changed files with 10 additions and 7 deletions
|
@ -2287,8 +2287,8 @@ public:
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
instance_of_cnetcleanup;
|
static CNetCleanup instance_of_cnetcleanup;
|
||||||
|
|
||||||
void CConnman::Interrupt()
|
void CConnman::Interrupt()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4086,4 +4086,5 @@ public:
|
||||||
mapOrphanTransactions.clear();
|
mapOrphanTransactions.clear();
|
||||||
mapOrphanTransactionsByPrev.clear();
|
mapOrphanTransactionsByPrev.clear();
|
||||||
}
|
}
|
||||||
} instance_of_cnetprocessingcleanup;
|
};
|
||||||
|
static CNetProcessingCleanup instance_of_cnetprocessingcleanup;
|
||||||
|
|
|
@ -21,7 +21,8 @@ struct UISignals {
|
||||||
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
|
boost::signals2::signal<CClientUIInterface::NotifyBlockTipSig> NotifyBlockTip;
|
||||||
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
|
boost::signals2::signal<CClientUIInterface::NotifyHeaderTipSig> NotifyHeaderTip;
|
||||||
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
|
boost::signals2::signal<CClientUIInterface::BannedListChangedSig> BannedListChanged;
|
||||||
} g_ui_signals;
|
};
|
||||||
|
static UISignals g_ui_signals;
|
||||||
|
|
||||||
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
|
#define ADD_SIGNALS_IMPL_WRAPPER(signal_name) \
|
||||||
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
boost::signals2::connection CClientUIInterface::signal_name##_connect(std::function<signal_name##Sig> fn) \
|
||||||
|
|
|
@ -77,7 +77,7 @@ bool CBlockIndexWorkComparator::operator()(const CBlockIndex *pa, const CBlockIn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CChainState g_chainstate;
|
static CChainState g_chainstate;
|
||||||
|
|
||||||
CChainState& ChainstateActive() { return g_chainstate; }
|
CChainState& ChainstateActive() { return g_chainstate; }
|
||||||
|
|
||||||
|
@ -1044,7 +1044,7 @@ bool CChainState::IsInitialBlockDownload() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr;
|
static CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr;
|
||||||
|
|
||||||
static void AlertNotify(const std::string& strMessage)
|
static void AlertNotify(const std::string& strMessage)
|
||||||
{
|
{
|
||||||
|
@ -4757,4 +4757,5 @@ public:
|
||||||
delete (*it1).second;
|
delete (*it1).second;
|
||||||
mapBlockIndex.clear();
|
mapBlockIndex.clear();
|
||||||
}
|
}
|
||||||
} instance_of_cmaincleanup;
|
};
|
||||||
|
static CMainCleanup instance_of_cmaincleanup;
|
||||||
|
|
Loading…
Reference in a new issue