ardupilot/libraries/StorageManager
Gustavo Jose de Sousa 0d1d960899 StorageManager: remove unnecessary calculations on addr for next area
When writting or reading a block, if the block doesn't fit the area where it begins, the next base address is always zero. Thus the calculations to define the next value of addr are unnecessary.

Here's a quick validity proof using the previous calculations:
    First: Considering the case where the block doesn't fit it's first area:
        That means that (count + addr > length), what makes:
            count = length - addr; (1)
        So the following operations:
            addr += count;
            addr -= length;
        Are the same as doing:
            addr = addr + count - length; (2)
        Using (1) and (2) we have:
            addr = addr + length - addr - length = 0

    Second: When the block fits the area where it's at:
        That means that variable count is not changed,
        thus (n -= count) evaluates to 0, which makes the loop exit.

Another change was (b += count;) being moved after the condition to break the loop, since we just need to move the block pointer when it doesn't fit the first area.
2015-08-07 20:52:20 +10:00
..
examples/StorageTest StorageManager: convert example from .pde to .cpp 2015-06-01 17:07:08 +10:00
StorageManager.cpp StorageManager: remove unnecessary calculations on addr for next area 2015-08-07 20:52:20 +10:00
StorageManager.h StorageManager: cope with a wider range of storage sizes 2014-08-13 21:35:26 +10:00