Reputation: 17265
Given two split values, seconds since epoch and µs, is one of the following preferable?
auto timestamp = system_clock::time_point(seconds(time_seconds) + microseconds(time_us));
or
auto timestamp = system_clock::time_point(seconds(time_seconds)) + microseconds(time_us);
Upvotes: 1
Views: 104
Reputation: 249103
It does not matter at all which one of those two you choose. It does however pay to have time_seconds
and time_us
as 64-bit integers--this cuts the whole operation from 5 instructions to 3 on x86_64. See: https://godbolt.org/g/8u1pYn
Upvotes: 1