From 9c11fdf80c838c60ec7616aa40c5e44ebc80f0f7 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 23 Feb 2016 13:30:41 -0800 Subject: [PATCH] Explicit std::function nullptr checks. Eliminates std::function check which tries to "_ZSt25__throw_bad_function_callv", along with 816 bytes of extra code, including some locale/wlocale/moneypunct nonsense. --- firmware/baseband/clock_recovery.hpp | 7 ++++++- firmware/baseband/packet_builder.hpp | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/firmware/baseband/clock_recovery.hpp b/firmware/baseband/clock_recovery.hpp index 91f4cf8f..9a6904a3 100644 --- a/firmware/baseband/clock_recovery.hpp +++ b/firmware/baseband/clock_recovery.hpp @@ -168,7 +168,12 @@ private: } void symbol_callback(const float symbol, const float lateness) { - symbol_handler(symbol); + // NOTE: This check is to avoid std::function nullptr check, which + // brings in "_ZSt25__throw_bad_function_callv" and a lot of extra code. + // TODO: Make symbol_handler known at compile time. + if( symbol_handler) { + symbol_handler(symbol); + } const float adjustment = error_filter(lateness); resampler.advance(adjustment); diff --git a/firmware/baseband/packet_builder.hpp b/firmware/baseband/packet_builder.hpp index e3293529..c8a9ea5b 100644 --- a/firmware/baseband/packet_builder.hpp +++ b/firmware/baseband/packet_builder.hpp @@ -89,8 +89,13 @@ public: } if( end(bit_history, packet.size()) ) { - packet.set_timestamp(Timestamp::now()); - payload_handler(packet); + // NOTE: This check is to avoid std::function nullptr check, which + // brings in "_ZSt25__throw_bad_function_callv" and a lot of extra code. + // TODO: Make payload_handler known at compile time. + if( payload_handler ) { + packet.set_timestamp(Timestamp::now()); + payload_handler(packet); + } reset_state(); } else { if( packet_truncated() ) {