summaryrefslogtreecommitdiff
path: root/toxcore/DHT.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-09 23:53:39 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-16 21:01:38 +0000
commit54066f338f185f2fbd6694d9a4877f42cbfa21c8 (patch)
treee056e50af1009bf373c040812e46cd1de8de9979 /toxcore/DHT.c
parent31ea1aa06e59d24d5196b17be9a7105d85c25080 (diff)
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.
Diffstat (limited to 'toxcore/DHT.c')
-rw-r--r--toxcore/DHT.c9
1 files changed, 0 insertions, 9 deletions
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
2690 2690
2691DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled) 2691DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled)
2692{ 2692{
2693 /* init time */
2694 unix_time_update();
2695
2696 if (net == nullptr) { 2693 if (net == nullptr) {
2697 return nullptr; 2694 return nullptr;
2698 } 2695 }
@@ -2741,8 +2738,6 @@ DHT *new_dht(const Logger *log, Networking_Core *net, bool holepunching_enabled)
2741 2738
2742void do_dht(DHT *dht) 2739void do_dht(DHT *dht)
2743{ 2740{
2744 unix_time_update();
2745
2746 if (dht->last_run == unix_time()) { 2741 if (dht->last_run == unix_time()) {
2747 return; 2742 return;
2748 } 2743 }
@@ -2963,8 +2958,6 @@ int dht_load(DHT *dht, const uint8_t *data, uint32_t length)
2963 */ 2958 */
2964bool dht_isconnected(const DHT *dht) 2959bool dht_isconnected(const DHT *dht)
2965{ 2960{
2966 unix_time_update();
2967
2968 for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { 2961 for (uint32_t i = 0; i < LCLIENT_LIST; ++i) {
2969 const Client_data *const client = &dht->close_clientlist[i]; 2962 const Client_data *const client = &dht->close_clientlist[i];
2970 2963
@@ -2982,8 +2975,6 @@ bool dht_isconnected(const DHT *dht)
2982 */ 2975 */
2983bool dht_non_lan_connected(const DHT *dht) 2976bool dht_non_lan_connected(const DHT *dht)
2984{ 2977{
2985 unix_time_update();
2986
2987 for (uint32_t i = 0; i < LCLIENT_LIST; ++i) { 2978 for (uint32_t i = 0; i < LCLIENT_LIST; ++i) {
2988 const Client_data *const client = &dht->close_clientlist[i]; 2979 const Client_data *const client = &dht->close_clientlist[i];
2989 2980