Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lv_subject_t Size #7649

Open
vwheeler63 opened this issue Jan 23, 2025 · 0 comments
Open

lv_subject_t Size #7649

vwheeler63 opened this issue Jan 23, 2025 · 0 comments

Comments

@vwheeler63
Copy link
Contributor

Introduce the problem

Hi, @kisvegabor

Proposal

What would you think of changing

typedef struct {
    lv_ll_t subs_ll;                    /**< Subscribers */
    uint32_t type   : 4;                /**< One of the LV_SUBJECT_TYPE_... values */
    uint32_t size   : 28;               /**< String buffer size or group length */
    lv_subject_value_t value;           /**< Current value */
    lv_subject_value_t prev_value;      /**< Previous value */
    uint32_t notify_restart_query : 1;  /**< If an Observer was deleted during notifcation, start notifying from the beginning. */
    void * user_data;                   /**< Additional parameter, can be used freely by user */
} lv_subject_t;

to

typedef struct {
    lv_ll_t subs_ll;                    /**< Subscribers */
    lv_subject_value_t value;           /**< Current value */
    lv_subject_value_t prev_value;      /**< Previous value */
    void * user_data;                   /**< Additional parameter, can be used freely by user */
    uint32_t type                 : 4;  /**< One of the LV_SUBJECT_TYPE_... values */
    uint32_t size                 : 27; /**< String buffer size or group length */
    uint32_t notify_restart_query : 1;  /**< If an Observer was deleted during notifcation, start notifying from the beginning. */
} lv_subject_t;

to save 4 bytes of memory (32 bytes => 28 bytes) for each lv_subject_t?

Since these are internal values, it would not break the API, and would limit the size of string buffers and group lists to 134217727. It might even be worth considering to reduce the number of bits in the size field even further to reserve a few bits for the future. Just a thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant