mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
refactor(uORB): out-line PublicationBase destructor to save flash
The ~PublicationBase() destructor was header-inline, so its null-check plus the orb_get_queue_size()/unadvertise() branch was emitted at every publication destruction site (PX4 links with bfd ld, no ICF, no LTO). Move it into Publication.cpp alongside the already out-lined advertise()/publish(), mirroring #27581. Saves 2.4 kB of flash on px4_fmu-v6x_default.
This commit is contained in:
@@ -45,6 +45,16 @@
|
||||
namespace uORB
|
||||
{
|
||||
|
||||
PublicationBase::~PublicationBase()
|
||||
{
|
||||
if (_handle != nullptr) {
|
||||
// don't automatically unadvertise queued publications (eg vehicle_command)
|
||||
if (Manager::orb_get_queue_size(_handle) == 1) {
|
||||
unadvertise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PublicationBase::advertise()
|
||||
{
|
||||
if (!advertised()) {
|
||||
|
||||
@@ -64,15 +64,7 @@ protected:
|
||||
|
||||
PublicationBase(ORB_ID id) : _orb_id(id) {}
|
||||
|
||||
~PublicationBase()
|
||||
{
|
||||
if (_handle != nullptr) {
|
||||
// don't automatically unadvertise queued publications (eg vehicle_command)
|
||||
if (Manager::orb_get_queue_size(_handle) == 1) {
|
||||
unadvertise();
|
||||
}
|
||||
}
|
||||
}
|
||||
~PublicationBase();
|
||||
|
||||
// type-independent publish; data points to a message of the topic's type
|
||||
bool publish(const void *data);
|
||||
|
||||
Reference in New Issue
Block a user