From 9c1e218b1f82867b7984b5d03bf088de692db6ef Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:42:34 -0800 Subject: [PATCH] refactor(platform): out-line ModuleParams::updateParams() to save flash (#29543) The base implementation, which walks the child list and then calls updateParamsImpl(), was defined in the class body. Every module that calls updateParams() on a parameter update therefore inlined the list walk. Define it in module_params.cpp next to setParent(). px4_fmu-v6x_default: 1917160 -> 1915056 bytes of text, -2104 B. Assisted-by: Claude:claude-fable-5-1 Co-authored-by: Balduin --- .../common/include/px4_platform_common/module_params.h | 9 +-------- platforms/common/module_params.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/platforms/common/include/px4_platform_common/module_params.h b/platforms/common/include/px4_platform_common/module_params.h index 7d954e09087..c88ade7d9ca 100644 --- a/platforms/common/include/px4_platform_common/module_params.h +++ b/platforms/common/include/px4_platform_common/module_params.h @@ -71,14 +71,7 @@ protected: * @brief Call this method whenever the module gets a parameter change notification. * It will automatically call updateParams() for all children, which then call updateParamsImpl(). */ - virtual void updateParams() - { - for (const auto &child : _children) { - child->updateParams(); - } - - updateParamsImpl(); - } + virtual void updateParams(); /** * @brief The implementation for this is generated with the macro DEFINE_PARAMETERS() diff --git a/platforms/common/module_params.cpp b/platforms/common/module_params.cpp index 1ae4e4cafc2..f39995e3afa 100644 --- a/platforms/common/module_params.cpp +++ b/platforms/common/module_params.cpp @@ -42,6 +42,15 @@ void ModuleParams::setParent(ModuleParams *parent) _parent = parent; } +void ModuleParams::updateParams() +{ + for (const auto &child : _children) { + child->updateParams(); + } + + updateParamsImpl(); +} + ModuleParams::~ModuleParams() { if (_parent) { _parent->_children.remove(this); }