From 4da2ae23029ea503527e2a43c33dbc873f99ca4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 18 Oct 2016 15:31:37 +0200 Subject: [PATCH] MavlinkOrbSubscription: optimize fields for size reorder & reduce instance to uint8_t (which is more than enough). Reduces sizeof(MavlinkOrbSubscription) from 40 to 24. On Pixracer this frees almost 2KB of RAM --- src/modules/mavlink/mavlink_orb_subscription.cpp | 6 +++--- src/modules/mavlink/mavlink_orb_subscription.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/mavlink/mavlink_orb_subscription.cpp b/src/modules/mavlink/mavlink_orb_subscription.cpp index a5023da8504..235e35a8a66 100644 --- a/src/modules/mavlink/mavlink_orb_subscription.cpp +++ b/src/modules/mavlink/mavlink_orb_subscription.cpp @@ -50,11 +50,11 @@ MavlinkOrbSubscription::MavlinkOrbSubscription(const orb_id_t topic, int instance) : next(nullptr), _topic(topic), - _instance(instance), _fd(-1), + _instance(instance), _published(false), - _last_pub_check(0), - _subscribe_from_beginning(false) + _subscribe_from_beginning(false), + _last_pub_check(0) { } diff --git a/src/modules/mavlink/mavlink_orb_subscription.h b/src/modules/mavlink/mavlink_orb_subscription.h index e5ab24d23b0..9154e6a2b8d 100644 --- a/src/modules/mavlink/mavlink_orb_subscription.h +++ b/src/modules/mavlink/mavlink_orb_subscription.h @@ -95,11 +95,11 @@ public: private: const orb_id_t _topic; ///< topic metadata - const int _instance; ///< get topic instance int _fd; ///< subscription handle + const uint8_t _instance; ///< get topic instance bool _published; ///< topic was ever published - hrt_abstime _last_pub_check; ///< when we checked last bool _subscribe_from_beginning; ///< we need to subscribe from the beginning, e.g. for vehicle_command_acks + hrt_abstime _last_pub_check; ///< when we checked last /* do not allow copying this class */ MavlinkOrbSubscription(const MavlinkOrbSubscription &);