summaryrefslogtreecommitdiff
path: root/toxcore/tox.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/tox.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/tox.c')
-rw-r--r--toxcore/tox.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index cd1b71f0..879b5c09 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -38,6 +38,7 @@
38#include "Messenger.h" 38#include "Messenger.h"
39#include "group.h" 39#include "group.h"
40#include "logger.h" 40#include "logger.h"
41#include "mono_time.h"
41 42
42#include "../toxencryptsave/defines.h" 43#include "../toxencryptsave/defines.h"
43 44
@@ -335,6 +336,8 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
335 return nullptr; 336 return nullptr;
336 } 337 }
337 338
339 unix_time_update();
340
338 Messenger_Options m_options = {0}; 341 Messenger_Options m_options = {0};
339 342
340 bool load_savedata_sk = false, load_savedata_tox = false; 343 bool load_savedata_sk = false, load_savedata_tox = false;
@@ -653,6 +656,8 @@ uint32_t tox_iteration_interval(const Tox *tox)
653 656
654void tox_iterate(Tox *tox, void *user_data) 657void tox_iterate(Tox *tox, void *user_data)
655{ 658{
659 unix_time_update();
660
656 Messenger *m = tox->m; 661 Messenger *m = tox->m;
657 struct Tox_Userdata tox_data = { tox, user_data }; 662 struct Tox_Userdata tox_data = { tox, user_data };
658 do_messenger(m, &tox_data); 663 do_messenger(m, &tox_data);