Permalink
Browse files

Performance enhancement

Patch by: michaelortmann

Dont call localtime every second, because the result is only used every minute
GH PR #666 ... Patch of the Beast!
  • Loading branch information...
michaelortmann authored and vanosg committed Oct 12, 2018
1 parent 2edf706 commit 91cc387598b036a6eb60dc1360e30c56946a0d25
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/main.c
View
@@ -636,6 +636,7 @@ static void core_secondly()
static int cnt = 0;
int miltime;
time_t nowmins;
int i;
do_check_timers(&utimer); /* Secondly timers */
cnt++;
@@ -650,10 +651,10 @@ static void core_secondly()
tell_mem_status_dcc(DP_STDOUT);
}
}
egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
nowmins = time(NULL) / 60;
if (nowmins > lastmin) {
int i = 0;
egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
i = 0;
/* Once a minute */
++lastmin;
@@ -1118,7 +1119,6 @@ int main(int arg_c, char **arg_v)
/* Initialize variables and stuff */
now = time(NULL);
chanset = NULL;
egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
lastmin = now / 60;
init_random();
init_mem();

0 comments on commit 91cc387

Please sign in to comment.