From 54900ca3fbc34225d95b54b111b6c9836c9d2e70 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 29 Dec 2016 11:00:47 -0500 Subject: [PATCH] Addition and subtraction can end immediately without performing any extra work if the operand is 0 --- Storage/Storage.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Storage/Storage.hpp b/Storage/Storage.hpp index 3feff4d5f..bc8d5a059 100644 --- a/Storage/Storage.hpp +++ b/Storage/Storage.hpp @@ -89,6 +89,8 @@ struct Time { inline Time operator + (const Time &other) const { + if(!other.length) return *this; + uint64_t result_length; uint64_t result_clock_rate; if(clock_rate == other.clock_rate) @@ -106,6 +108,8 @@ struct Time { inline Time &operator += (const Time &other) { + if(!other.length) return *this; + uint64_t result_length; uint64_t result_clock_rate; if(clock_rate == other.clock_rate) @@ -124,6 +128,8 @@ struct Time { inline Time operator - (const Time &other) const { + if(!other.length) return *this; + uint64_t result_length; uint64_t result_clock_rate; if(clock_rate == other.clock_rate) @@ -141,6 +147,8 @@ struct Time { inline Time operator -= (const Time &other) { + if(!other.length) return *this; + uint64_t result_length; uint64_t result_clock_rate; if(clock_rate == other.clock_rate)