summaryrefslogtreecommitdiff
path: root/mozglue
diff options
context:
space:
mode:
authorBotond Ballo <botond@mozilla.com>2023-10-01 19:37:49 +0200
committerMoonchild <moonchild@palemoon.org>2023-10-01 19:37:49 +0200
commit1337373ee1f8d93db13e923d0b35b928f3ac9b2e (patch)
tree38a619ec6d84ca52f624ecc47ea841c44e27844a /mozglue
parentefc3e99b90b248e3ea12316852dc9ac7e2a959e0 (diff)
downloaduxp-1337373ee1f8d93db13e923d0b35b928f3ac9b2e.tar.gz
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
Diffstat (limited to 'mozglue')
-rw-r--r--mozglue/misc/TimeStamp.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/mozglue/misc/TimeStamp.h b/mozglue/misc/TimeStamp.h
index 019393b284..5f5886abc7 100644
--- a/mozglue/misc/TimeStamp.h
+++ b/mozglue/misc/TimeStamp.h
@@ -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.