1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 03:32:01 +00:00

Addition and subtraction can end immediately without performing any extra work if the operand is 0

This commit is contained in:
Thomas Harte 2016-12-29 11:00:47 -05:00 committed by GitHub
parent a8bc9d830e
commit 54900ca3fb

View File

@ -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)