mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Addition and subtraction can end immediately without performing any extra work if the operand is 0
This commit is contained in:
parent
a8bc9d830e
commit
54900ca3fb
@ -89,6 +89,8 @@ struct Time {
|
|||||||
|
|
||||||
inline Time operator + (const Time &other) const
|
inline Time operator + (const Time &other) const
|
||||||
{
|
{
|
||||||
|
if(!other.length) return *this;
|
||||||
|
|
||||||
uint64_t result_length;
|
uint64_t result_length;
|
||||||
uint64_t result_clock_rate;
|
uint64_t result_clock_rate;
|
||||||
if(clock_rate == other.clock_rate)
|
if(clock_rate == other.clock_rate)
|
||||||
@ -106,6 +108,8 @@ struct Time {
|
|||||||
|
|
||||||
inline Time &operator += (const Time &other)
|
inline Time &operator += (const Time &other)
|
||||||
{
|
{
|
||||||
|
if(!other.length) return *this;
|
||||||
|
|
||||||
uint64_t result_length;
|
uint64_t result_length;
|
||||||
uint64_t result_clock_rate;
|
uint64_t result_clock_rate;
|
||||||
if(clock_rate == other.clock_rate)
|
if(clock_rate == other.clock_rate)
|
||||||
@ -124,6 +128,8 @@ struct Time {
|
|||||||
|
|
||||||
inline Time operator - (const Time &other) const
|
inline Time operator - (const Time &other) const
|
||||||
{
|
{
|
||||||
|
if(!other.length) return *this;
|
||||||
|
|
||||||
uint64_t result_length;
|
uint64_t result_length;
|
||||||
uint64_t result_clock_rate;
|
uint64_t result_clock_rate;
|
||||||
if(clock_rate == other.clock_rate)
|
if(clock_rate == other.clock_rate)
|
||||||
@ -141,6 +147,8 @@ struct Time {
|
|||||||
|
|
||||||
inline Time operator -= (const Time &other)
|
inline Time operator -= (const Time &other)
|
||||||
{
|
{
|
||||||
|
if(!other.length) return *this;
|
||||||
|
|
||||||
uint64_t result_length;
|
uint64_t result_length;
|
||||||
uint64_t result_clock_rate;
|
uint64_t result_clock_rate;
|
||||||
if(clock_rate == other.clock_rate)
|
if(clock_rate == other.clock_rate)
|
||||||
|
Loading…
Reference in New Issue
Block a user