avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [avr-libc-commit] [2358] Reverted month_length() back


From: Weddington, Eric
Subject: Re: [avr-libc-dev] [avr-libc-commit] [2358] Reverted month_length() back to using the 'knuckles' algorithm.
Date: Wed, 24 Apr 2013 05:06:32 +0000

Hi Mike,

See inline below...

> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden
> On Behalf Of Mike Rice
> Sent: Tuesday, April 23, 2013 3:30 PM
> To: address@hidden
> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-libc-commit



reply via email to

[Prev in Thread] Current Thread [Next in Thread]