From 54066f338f185f2fbd6694d9a4877f42cbfa21c8 Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 9 Aug 2018 23:53:39 +0000 Subject: Reduce the number of times `unix_time_update` is called. Reduced by, e.g.: * `file_transfer_test`: 33% of the `clock_gettime` calls. * `tox_many_test`: 53% of the `clock_gettime` calls. Other tests will see similar improvements. Real world applications will be closer to 40-50% improvement, since tox_many_test has 100 nodes, while file_transfer_test has 2 nodes. --- toxcore/DHT.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'toxcore/DHT.c') diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 37dd9385..94928b75 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c @@ -2690,9 +2690,6 @@ static int cryptopacket_handle(void *object, IP_Port source, const uint8_t *pack DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) { - /* init time */ - unix_time_update(); - if (net == nullptr) { return nullptr; } @@ -2741,8 +2738,6 @@ DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) void do_dht(DHT *dht) { - unix_time_update(); - if (dht->last_run == unix_time()) { return; } @@ -2963,8 +2958,6 @@ int dht_load(DHT *dht, const uint8_t *data, uint32_t length) */ bool dht_isconnected(const DHT *dht) { - unix_time_update(); - for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { const Client_data *const client = &dht->close_clientlist[i]; @@ -2982,8 +2975,6 @@ bool dht_isconnected(const DHT *dht) */ bool dht_non_lan_connected(const DHT *dht) { - unix_time_update(); - for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { const Client_data *const client = &dht->close_clientlist[i]; -- cgit v1.2.3