From 9b2547a51eb365a0944043cbb6201f6c3f5ce47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Joseph?= Date: Thu, 26 Mar 2015 23:08:27 +0100 Subject: [PATCH] Slight simplification of compareScratch() No need to compare scratch1->length and scratch2->length, we already know they're the same from the if statement. Followed that up with some further simplification to that function. --- Arduino/rgb_scratch/rgb_scratch.ino | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Arduino/rgb_scratch/rgb_scratch.ino b/Arduino/rgb_scratch/rgb_scratch.ino index 75361f5..c8e81c6 100644 --- a/Arduino/rgb_scratch/rgb_scratch.ino +++ b/Arduino/rgb_scratch/rgb_scratch.ino @@ -46,25 +46,18 @@ void colorWipe( uint32_t c, uint8_t wait ) { bool compareScratch( ScratchData * scratch1, ScratchData * scratch2 ) { - bool matched = true; - if ( scratch1->length != scratch2->length ) { - matched = false; + return false; } else { - int length = min( scratch1->length, scratch2->length ); - int i = 0; - - while ( i < length ) { + for( int i=0; scratch1->length; i++ ) { if ( scratch1->data[i] != scratch2->data[i] ) { - matched = false; - i = length; + return false; } - i++; } } - return matched; + return true; } // the loop routine runs over and over again forever: