commit | acefe88a4997c8109994c8aa249c077a55e8e4eb | [log] [tgz] |
---|---|---|
author | Wyatt Hepler <hepler@google.com> | Fri Nov 19 09:51:51 2021 -0800 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Fri Nov 19 23:36:31 2021 +0000 |
tree | 78754f4b74f6ae84ff657573744ce565aebe6452 | |
parent | b19d586c06e3b9eef13a99092a231f060b90bc26 [diff] |
pw_function: Size optimizations Three size optimizations, ordered from most to least impactful: - Remove the template parameters for NullFunctionTarget. The NullFunctionTarget is the same for all instantiations of pw::Function. Since it was a template, though, every unique pw::Function instantiation created new copies of the NullFunctionTarget virtual functions. This change drops the NullFunctionTarget template parameters. It uses a single FunctionTarget<void> implementation for all pw::Function instantiations. This does mean that the operator() function is called with extra arguments -- but it's illegal to call a null function anyway. MoveInitializeTo() and IsNull() functions are moved to a common base class shared by all pw::Function instantiations. - Provide default implementation of the IsNull() virtual function. It is false for all derived classes except NullFunctionTarget, so the implementation can be shared across pw::Function instantiations. - Forward arguments to operator(). In theory this can avoid unnecessary copies of the arguments, though the compiler should be able to optimize this. This has a very small size savings on optimized builds. Change-Id: I4cc8caccc52d899d1a0f46cdf9f367e552f3e6e0 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/70160 Reviewed-by: Ewout van Bekkum <ewout@google.com> Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/