1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 01:19:03 +00:00

Minor efficiencies: avoid multiple expansions of function calls in TIMEVAL_* macros

This commit is contained in:
dmiller
2024-06-26 21:54:28 +00:00
parent 136e1c6ed7
commit 7b20a38099
5 changed files with 44 additions and 26 deletions

View File

@@ -301,17 +301,18 @@ bool keyWasPressed()
option. */
if (o.stats_interval != 0.0) {
struct timeval now;
time_t usec_interval = o.stats_interval * 1000000;
gettimeofday(&now, NULL);
if (stats_time.tv_sec == 0) {
/* Initialize the scheduled stats time. */
stats_time = *o.getStartTime();
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
TIMEVAL_ADD(stats_time, stats_time, usec_interval);
}
if (TIMEVAL_AFTER(now, stats_time)) {
/* Advance to the next print time. */
TIMEVAL_ADD(stats_time, stats_time, (time_t) (o.stats_interval * 1000000));
TIMEVAL_ADD(stats_time, stats_time, usec_interval);
/* If it's still in the past, catch it up to the present,
* plus half a second to avoid double-printing without any progress. */
if (TIMEVAL_AFTER(now, stats_time))