Issue #2323 - Part 1: Add Min()/Max() methods to TimeDuration.

Just some helper functions to make time comparisons in the correct data
format easier.

See BZ 1321885
This commit is contained in:
Botond Ballo 2023-10-01 19:37:49 +02:00 committed by roytam1
commit c78ecee3f2

View file

@ -7,6 +7,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"
@ -173,6 +174,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.