From 50410efe9e38d1f8b9f22a092171ceb55ebe23d1 Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Sun, 29 Dec 2019 22:54:22 -0700 Subject: Replace days_to_seconds function with macro This function was a [huge] waste of processing power and complexity. Replaced with a macro for easier readability of code, since 86400 (the number of seconds in 24 hours) isn't immediately obvious what it is. Now it is referenced by the macro SECONDS_IN_DAY. --- src/main.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/main.c b/src/main.c index 673fd66..674fa14 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,8 @@ #include #include +#define SECONDS_IN_DAY 86400; + /** * Prints the helptext @@ -45,19 +47,6 @@ void usage() { } -/** - * Converts the given day count to seconds (multiplies by the number of seconds - * in a day, 86400). - * - * @param days Day count to convert to seconds - * - * @return long Number of total seconds in the given day duration - */ -long days_to_seconds(int days) { - return days * 86400; -} - - /** * Writes the current timestamp to the specified lastlogin file * @@ -178,7 +167,7 @@ int main(int argc, char* argv[]) { // Set time-related values now = time(NULL); - threshold = days_to_seconds(days); + threshold = days * SECONDS_IN_DAY; lastlogin = fread_long(lastlogin_path); if(lastlogin == -1) { -- cgit v1.2.3