Commit cd1ab8b9 authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook Github Bot

Remove return value check in folly::chrono::coarse_monotonic_clock

Summary: This shaves off 0.5ns

Reviewed By: yfeldblum

Differential Revision: D10320634

fbshipit-source-id: 1a790df14b128b3b02c810ec45ba48c2ce5e4612
parent e899e1af
...@@ -168,17 +168,18 @@ struct coarse_steady_clock { ...@@ -168,17 +168,18 @@ struct coarse_steady_clock {
using time_point = std::chrono::time_point<coarse_steady_clock, duration>; using time_point = std::chrono::time_point<coarse_steady_clock, duration>;
constexpr static bool is_steady = true; constexpr static bool is_steady = true;
static time_point now() { static time_point now() noexcept {
#ifndef CLOCK_MONOTONIC_COARSE #ifndef CLOCK_MONOTONIC_COARSE
return time_point(std::chrono::duration_cast<duration>( return time_point(std::chrono::duration_cast<duration>(
std::chrono::steady_clock::now().time_since_epoch())); std::chrono::steady_clock::now().time_since_epoch()));
#else #else
timespec ts; timespec ts;
auto ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); auto ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
if (ret != 0) { if (kIsDebug && (ret != 0)) {
throw_exception<std::runtime_error>( throw_exception<std::runtime_error>(
"Error using CLOCK_MONOTONIC_COARSE."); "Error using CLOCK_MONOTONIC_COARSE.");
} }
return time_point(std::chrono::duration_cast<duration>( return time_point(std::chrono::duration_cast<duration>(
std::chrono::seconds(ts.tv_sec) + std::chrono::seconds(ts.tv_sec) +
std::chrono::nanoseconds(ts.tv_nsec))); std::chrono::nanoseconds(ts.tv_nsec)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment