зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1039924 part 7 - Add unary minus operator to BaseTimeDuration; r=froydnj
This patch adds the unary minus operator so, for example, we can write: TimeDuration sinceBeforeYourSunBurnedHot = -TimeDuration::Forever();
This commit is contained in:
Родитель
9f07908ee4
Коммит
2268355a2b
|
@ -160,6 +160,21 @@ public:
|
|||
mValue = ValueCalculator::Subtract(mValue, aOther.mValue);
|
||||
return *this;
|
||||
}
|
||||
BaseTimeDuration operator-() const
|
||||
{
|
||||
// We don't just use FromTicks(ValueCalculator::Subtract(0, mValue))
|
||||
// since that won't give the correct result for -TimeDuration::Forever().
|
||||
int64_t ticks;
|
||||
if (mValue == INT64_MAX) {
|
||||
ticks = INT64_MIN;
|
||||
} else if (mValue == INT64_MIN) {
|
||||
ticks = INT64_MAX;
|
||||
} else {
|
||||
ticks = -mValue;
|
||||
}
|
||||
|
||||
return FromTicks(ticks);
|
||||
}
|
||||
|
||||
private:
|
||||
// Block double multiplier (slower, imprecise if long duration) - Bug 853398.
|
||||
|
|
Загрузка…
Ссылка в новой задаче