[hackers] [sbase] optimized isleap() function || Willem van de Krol

From: <git_AT_suckless.org>
Date: Fri, 04 Jul 2014 22:47:25 +0200

commit 5721deb2c4b5dffa87f9ee481831882eb02dc7c8
Author: Willem van de Krol <008054_AT_jfc.nl>
Date: Fri Jul 4 22:00:04 2014 +0200

    optimized isleap() function

diff --git a/cal.c b/cal.c
index 7fca626..8faf3de 100644
--- a/cal.c
+++ b/cal.c
_AT_@ -93,15 +93,11 @@ dayofweek(int year, int month, int day, int fday)
 static bool
 isleap(int year)
 {
- bool leap = false;
-
- if(year % 4 == 0)
- leap = true;
- if(year % 100 == 0)
- leap = false;
         if(year % 400 == 0)
- leap = true;
- return leap;
+ return true;
+ if(year % 100 == 0)
+ return false;
+ return (year % 4 == 0);
 }
 
 static void
Received on Fri Jul 04 2014 - 22:47:25 CEST

This archive was generated by hypermail 2.3.0 : Fri Jul 04 2014 - 22:48:08 CEST