From dbec7cf9693fb2e9566b590d2d3c95386ae47c66 Mon Sep 17 00:00:00 2001 From: Willem van de Krol <008054@jfc.nl> Date: Fri, 4 Jul 2014 22:00:04 +0200 Subject: [PATCH 1/2] optimized isleap() function --- cal.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cal.c b/cal.c index 7fca626..8faf3de 100644 --- a/cal.c +++ b/cal.c @@ -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 -- 2.0.1