Skip to content

Commit f318473

Browse files
committed
Streamline time computation
No functional change.
1 parent b1a4a18 commit f318473

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/misc.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ const string engine_info(bool to_uci) {
5959
}
6060

6161

62-
/// Convert system time to milliseconds. That's all we need.
63-
64-
Time::point Time::now() {
65-
sys_time_t t; system_time(&t); return time_to_msec(t);
66-
}
67-
68-
6962
/// Debug functions used mainly to collect run-time statistics
7063

7164
static uint64_t hits[2], means[2];

src/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct Log : public std::ofstream {
4545

4646
namespace Time {
4747
typedef int64_t point;
48-
point now();
48+
inline point now() { return system_time_to_msec(); }
4949
}
5050

5151

src/platform.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ typedef unsigned __int64 uint64_t;
4545
#ifndef _WIN32 // Linux - Unix
4646

4747
# include <sys/time.h>
48-
typedef timeval sys_time_t;
4948

50-
inline void system_time(sys_time_t* t) { gettimeofday(t, NULL); }
51-
inline int64_t time_to_msec(const sys_time_t& t) { return t.tv_sec * 1000LL + t.tv_usec / 1000; }
49+
inline int64_t system_time_to_msec() {
50+
timeval t;
51+
gettimeofday(&t, NULL);
52+
return t.tv_sec * 1000LL + t.tv_usec / 1000;
53+
}
5254

5355
# include <pthread.h>
5456
typedef pthread_mutex_t Lock;
@@ -71,10 +73,12 @@ typedef void*(*pt_start_fn)(void*);
7173
#else // Windows and MinGW
7274

7375
# include <sys/timeb.h>
74-
typedef _timeb sys_time_t;
7576

76-
inline void system_time(sys_time_t* t) { _ftime(t); }
77-
inline int64_t time_to_msec(const sys_time_t& t) { return t.time * 1000LL + t.millitm; }
77+
inline int64_t system_time_to_msec() {
78+
_timeb t;
79+
_ftime(&t);
80+
return t.time * 1000LL + t.millitm;
81+
}
7882

7983
#ifndef NOMINMAX
8084
# define NOMINMAX // disable macros min() and max()

0 commit comments

Comments
 (0)