From 5721deb2c4b5dffa87f9ee481831882eb02dc7c8 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] 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