Skip to content

Commit

Permalink
uORBDeviceNode: move flags from SubscriberData to UpdateIntervalData
Browse files Browse the repository at this point in the history
As there is only one bit used in 'flags', and it is only used in case
update_interval is not null, we can move the bit to UpdateIntervalData.

The size of UpdateIntervalData does not increase (on 32 bit).

Reduces RAM usage by 3.6KB (tested on a Pixracer).
  • Loading branch information
bkueng authored and LorenzMeier committed Nov 7, 2018
1 parent 90cee2d commit e91db7b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modules/uORB/uORBDeviceNode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,23 @@ class uORB::DeviceNode : public cdev::CDev

private:
struct UpdateIntervalData {
unsigned interval; /**< if nonzero minimum interval between updates */
struct hrt_call update_call; /**< deferred wakeup call if update_period is nonzero */
#ifndef __PX4_NUTTX
uint64_t last_update; /**< time at which the last update was provided, used when update_interval is nonzero */
#endif
unsigned interval; /**< if nonzero minimum interval between updates */
bool update_reported;
};
struct SubscriberData {
~SubscriberData() { if (update_interval) { delete (update_interval); } }

unsigned generation; /**< last generation the subscriber has seen */
int flags; /**< lowest 8 bits: priority of publisher, 9. bit: update_reported bit */
UpdateIntervalData *update_interval; /**< if null, no update interval */

bool update_reported() const { return flags & (1 << 8); }
void set_update_reported(bool update_reported_flag) { flags = (flags & ~(1 << 8)) | (((int)update_reported_flag) << 8); }
// these flags are only used if update_interval != null
bool update_reported() const { return update_interval ? update_interval->update_reported : false; }
void set_update_reported(bool update_reported_flag)
{ if (update_interval) { update_interval->update_reported = update_reported_flag; } }
};

const struct orb_metadata *_meta; /**< object metadata information */
Expand Down

0 comments on commit e91db7b

Please sign in to comment.