TheCoolest:
Wow! That's impressive! Is subtraction on AVR so much faster than addition?
I haven't really studied the AVR architecture or any fine-optimization techniques, but 30% is a very substantial increase in performance.Thanks a lot for your time in looking at the code and helping out with the optimizations.
- Arthur
-
No, it is the comparing with zero that is faster than comparing with nonzero const; and % is just expensive.
-
You're welcome,
There is little room to optimize (you can check this by commenting out the lowest level functions).
The line() is now a call to rectangle, there might be some gain making it dedicated.
The code looks quite good, good layered design, clear function and variable names and very little comments.
some remarks:
-
Point of attention is that there is a begin() an init() and a clear(), sounds like one to many
==> merge begin() and init() into one. Some of the constants in init() could be parameters for begin(); // #define them. -
swap could be inlined
-
remove all the testing of x and y if (x >= LCD_X || y >= LCD_Y) return; or change signature and return FAIL/SUCCESS.
now the user just don't know if a call did something when it returns. -
from write() * if (data < 0x20 || data > 0x7F) return 0;* you could also map non printable data on space, might save some layout. (design choice)
-
clear() this->m_Position = 0; is not needed as it is set in gotoXY()
-
BufLen is a #define ==> BUFLEN should be used, more consistent style
-
rectangle code could use some explaining.
just my 2 cents ,