Hi Mike,

See inline below...

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]
> On Behalf Of Mike Rice
> Sent: Tuesday, April 23, 2013 3:30 PM
> To: [email protected]
> Subject: [avr-libc-commit] [2358] Reverted month_length() back to using
> the 'knuckles' algorithm.
> 

> Log Message:
> -----------
> Reverted month_length() back to using the 'knuckles' algorithm. Easier
> to understand, and a couple words less FLASH.
<snip> 
> ===================================================================
> --- trunk/avr-libc/libc/time/month_length.c   2013-04-21 16:25:30 UTC
> (rev 2357)
> +++ trunk/avr-libc/libc/time/month_length.c   2013-04-23 22:30:20 UTC
> (rev 2358)
> @@ -38,7 +38,11 @@
>  uint8_t
>  month_length(int year, uint8_t month)
>  {
> -    if (month == 2) return 28 + is_leap_year(year);
> +    if (month == 2)
> +        return 28 + is_leap_year(year);

Thanks for putting that on two lines. It reads better.

> 
> -    return 30 + ((month + month / 8) & 1);

You're dividing by 8. Did you try replacing the divide with a right shift? 
Would that get you better code size?


> +    /* 'knuckles' algorithm */
> +    if (month > 7)
> +        month++;
> +    return 30 + (month & 1);
>  }
> 
> 
> _______________________________________________
> avr-libc-commit mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/avr-libc-commit

_______________________________________________
AVR-libc-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to