diff options
author | Aaron Ball <nullspoon@oper.io> | 2019-12-29 22:54:22 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2019-12-29 22:54:22 -0700 |
commit | 50410efe9e38d1f8b9f22a092171ceb55ebe23d1 (patch) | |
tree | 90845d49d901189cb47b7cf46bda8c81dc2fcfc8 | |
parent | f439428c1a5b82fa7682f7f45fa60290c3f7cf74 (diff) | |
download | terminus-50410efe9e38d1f8b9f22a092171ceb55ebe23d1.tar.gz terminus-50410efe9e38d1f8b9f22a092171ceb55ebe23d1.tar.xz |
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.
-rw-r--r-- | src/main.c | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -19,6 +19,8 @@ #include <string.h> #include <time.h> +#define SECONDS_IN_DAY 86400; + /** * Prints the helptext @@ -46,19 +48,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 * * @param path Path to the 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) { |