Skip to content

Commit

Permalink
Actually cache the results of timespan_t::{zero,min,max}.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazorlion authored and scamille committed Oct 5, 2019
1 parent e03c1f9 commit 1c80224
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions engine/sc_timespan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,22 @@ namespace timespan_adl_barrier
return timespan_t(t);
}

static constexpr timespan_t zero()
static timespan_t zero()
{
return timespan_t();
static constexpr timespan_t cached_zero = timespan_t();
return cached_zero;
}
static constexpr timespan_t max()
static timespan_t max()
{
return timespan_t(std::numeric_limits<time_t>::max());
static constexpr timespan_t cached_max = timespan_t( std::numeric_limits<time_t>::max() );
return cached_max;
}
static constexpr timespan_t min()
static timespan_t min()
{
return std::is_floating_point<time_t>::value ? timespan_t(-std::numeric_limits<time_t>::max()) :
timespan_t(std::numeric_limits<time_t>::min());
static constexpr timespan_t cached_min = std::is_floating_point<time_t>::value
? timespan_t( -std::numeric_limits<time_t>::max() )
: timespan_t( std::numeric_limits<time_t>::min() );
return cached_min;
}
};

Expand Down

0 comments on commit 1c80224

Please sign in to comment.