Closed Bug 1197145 Opened 6 years ago Closed 6 years ago

Add easy zero/bool checks to TimeDuration and TimeStamp

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: gerald, Assigned: gerald)

Details

Attachments

(1 file, 1 obsolete file)

I've found myself wanting a quick check for unit-less 0-values on [Base]TimeDuration objects, as currently this can only be done quite verbosely, e.g. |if (duration == TimeDuration(0)|.
By extension, the same could be useful for TimeStamp.

There is already a TimeStamp::IsNull().

Proposed additions:
1. |bool BaseTimeDuration::IsZero() const|, for consistency with TimeStamp::IsNull().
2. |explicit BaseTimeDuration::operator bool() const|, for easy |if (duration)| tests.
3. |explicit TimeStamp::operator bool() const|, for easy |if (timestamp)| tests.
Implementation of BaseTimeDuration::IsZero(), BaseTimeDuration::operator bool(), TimeStamp::operator bool().

Happy to discuss whether we actually need&want any/all of these.
Also I could split them in separate patches if preferred.
Assignee: nobody → gsquelart
Attachment #8650971 - Flags: review?(nfroyd)
(Sorry for the new rev, fixed a compilation error on Windows.)

Implementation of BaseTimeDuration::IsZero(), BaseTimeDuration::operator bool(), TimeStamp::operator bool().

Happy to discuss whether we actually need&want any/all of these.
Also I could split them in separate patches if preferred.
Attachment #8650971 - Attachment is obsolete: true
Attachment #8650971 - Flags: review?(nfroyd)
Attachment #8650998 - Flags: review?(nfroyd)
Attachment #8650998 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/332b56e30115
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
You need to log in before you can comment on or make changes to this bug.