The 'elegant' solution, while it looks pretty, is sometimes the Sirens
song. Take the often used example for testing Leap years...
int is_leap_year(int year){
return (year%4==0)?( (year%100==0)? ( (year%400==0)? 1 : 0) : 1) : 0;
}
An elegant 1 liner, which compiles to ~44 bytes. But the brutishly
ugly, multi line method I used in the library compiles to 38, and most
people find it easier to understand.
In general, I have found that breaking up those one liners into
multiple lines, will often result in smaller and faster code. Not
always, but usually.
_______________________________________________
AVR-libc-dev mailing list
AVR-libc-dev@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev