Index: base/time/time.cc |
diff --git a/base/time/time.cc b/base/time/time.cc |
index bf6c998ebf8cd2dae00b08dfa08e16f011f7503f..9834188597d479038b7bca055d2584feea091913 100644 |
--- a/base/time/time.cc |
+++ b/base/time/time.cc |
@@ -97,20 +97,21 @@ |
return delta_; |
} |
-int64 TimeDelta::SaturatedAdd(int64 value) const { |
- CheckedNumeric<int64> rv(delta_); |
+namespace time_internal { |
+ |
+int64 SaturatedAdd(TimeDelta delta, int64 value) { |
+ CheckedNumeric<int64> rv(delta.delta_); |
rv += value; |
return FromCheckedNumeric(rv); |
} |
-int64 TimeDelta::SaturatedSub(int64 value) const { |
- CheckedNumeric<int64> rv(delta_); |
+int64 SaturatedSub(TimeDelta delta, int64 value) { |
+ CheckedNumeric<int64> rv(delta.delta_); |
rv -= value; |
return FromCheckedNumeric(rv); |
} |
-// static |
-int64 TimeDelta::FromCheckedNumeric(const CheckedNumeric<int64> value) { |
+int64 FromCheckedNumeric(const CheckedNumeric<int64> value) { |
if (value.IsValid()) |
return value.ValueUnsafe(); |
@@ -123,6 +124,8 @@ |
limit = -limit; |
return value.ValueOrDefault(limit); |
} |
+ |
+} // namespace time_internal |
std::ostream& operator<<(std::ostream& os, TimeDelta time_delta) { |
return os << time_delta.InSecondsF() << "s"; |
@@ -305,15 +308,12 @@ |
TimeDelta tick_interval) const { |
// |interval_offset| is the offset from |this| to the next multiple of |
// |tick_interval| after |tick_phase|, possibly negative if in the past. |
- TimeDelta interval_offset = TimeDelta::FromInternalValue( |
- (tick_phase - *this).ToInternalValue() % tick_interval.ToInternalValue()); |
+ TimeDelta interval_offset = (tick_phase - *this) % tick_interval; |
// If |this| is exactly on the interval (i.e. offset==0), don't adjust. |
// Otherwise, if |tick_phase| was in the past, adjust forward to the next |
// tick after |this|. |
- if (interval_offset.ToInternalValue() != 0 && tick_phase < *this) { |
+ if (!interval_offset.is_zero() && tick_phase < *this) |
interval_offset += tick_interval; |
- } |
- |
return *this + interval_offset; |
} |