Bug 1321885 - Add Max() and Min() methods to TimeDuration. r=froydnj

MozReview-Commit-ID: 4WvRa3ZSrmP

--HG--
extra : rebase_source : d7433ab7cdb949194e494568f0bf94b91639e27e
extra : source : bac442a609767fbb21b266dbd719d6eb968fbf3d
This commit is contained in:
Botond Ballo 2016-07-27 14:07:57 -04:00
Родитель 3228e94e88
Коммит 71a6962e97
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -8,6 +8,7 @@
#define mozilla_TimeStamp_h
#include <stdint.h>
#include <algorithm> // for std::min, std::max
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/FloatingPoint.h"
@ -175,6 +176,17 @@ public:
return FromTicks(ticks);
}
static BaseTimeDuration Max(const BaseTimeDuration& aA,
const BaseTimeDuration& aB)
{
return FromTicks(std::max(aA.mValue, aB.mValue));
}
static BaseTimeDuration Min(const BaseTimeDuration& aA,
const BaseTimeDuration& aB)
{
return FromTicks(std::min(aA.mValue, aB.mValue));
}
private:
// Block double multiplier (slower, imprecise if long duration) - Bug 853398.
// If required, use MultDouble explicitly and with care.