Reduce memory footprint #1

Merged
mic159 merged 1 commits from master into master 2014-03-02 17:06:19 +04:00
mic159 commented 2014-02-20 16:27:50 +04:00 (Migrated from github.com)

Currently, Bounce2 uses 12 bytes of RAM per instance.
By packing a few of the boolean fields together, and reducing the size of the interval, I have reduced it to 8 bytes.

The interval_millis field should never realistically be set to over a uint16_t, which is 65535 (65.5 seconds).
A uint16_t is half the size of a long.

I also couldn't see why the read() function was returning a uint8_t, not a bool, so I changed it.

Currently, Bounce2 uses 12 bytes of RAM per instance. By packing a few of the boolean fields together, and reducing the size of the interval, I have reduced it to 8 bytes. The interval_millis field should never realistically be set to over a uint16_t, which is 65535 (65.5 seconds). A uint16_t is half the size of a long. I also couldn't see why the read() function was returning a uint8_t, not a bool, so I changed it.
thomasfredericks commented 2014-02-20 17:40:55 +04:00 (Migrated from github.com)

Hi, thanks for the commit. I am on vacation and will check it out in about
a week.
On Feb 20, 2014 7:27 AM, "Michael" notifications@github.com wrote:

Currently, Bounce2 uses 12 bytes of RAM per instance.
By packing a few of the boolean fields together, and reducing the size of
the interval, I have reduced it to 8 bytes.

The interval_millis field should never realistically be set to over a
uint16_t, which is 65535 (65.5 seconds).
A uint16_t is half the size of a long.

I also couldn't see why the read() function was returning a uint8_t, not a

bool, so I changed it.

You can merge this Pull Request by running

git pull https://github.com/mic159/Bounce-Arduino-Wiring master

Or view, comment on, or merge it at:

https://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1
Commit Summary

  • Reduce memory footprint

File Changes

Patch Links:

https://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1.patch

Reply to this email directly or view it on GitHubhttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1
.

Hi, thanks for the commit. I am on vacation and will check it out in about a week. On Feb 20, 2014 7:27 AM, "Michael" notifications@github.com wrote: > Currently, Bounce2 uses 12 bytes of RAM per instance. > By packing a few of the boolean fields together, and reducing the size of > the interval, I have reduced it to 8 bytes. > > The interval_millis field should never realistically be set to over a > uint16_t, which is 65535 (65.5 seconds). > A uint16_t is half the size of a long. > > I also couldn't see why the read() function was returning a uint8_t, not a > > ## bool, so I changed it. > > You can merge this Pull Request by running > > git pull https://github.com/mic159/Bounce-Arduino-Wiring master > > Or view, comment on, or merge it at: > > https://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1 > Commit Summary > - Reduce memory footprint > > File Changes > - _M_ Bounce2/Bounce2.cpphttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1/files#diff-0(75) > - _M_ Bounce2/Bounce2.hhttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1/files#diff-1(12) > > Patch Links: > > - > https://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1.patch > - https://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1.diff > > ## > > Reply to this email directly or view it on GitHubhttps://github.com/thomasfredericks/Bounce-Arduino-Wiring/pull/1 > .
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Max/thomasfredericks_Bounce2#1