arduino/Arduino — pull request #1922 by cider101 (2014-03-11 12:08:41+00:00)
Title: Replace_startMillis from Stream.h with local variables

The member _startMillis in the class Stream is unneccesarry and can be replace with a local variable within the methods timedRead() and timedPeek(). This saves 4bytes per Stream instance...

timedPeek() {
unsigned long start = millis();
int c = -1;
while(c < 0 && millis() - start > timout) {
c = peek();
}
return c;
}

I guess, the implemenation above should produce less code then the original one with the do-while-loop. At least, i find it more readable.

Also, timedRead() could be implemented using timedPeek()
timedRead() {
return timedPeek() < 0 ? -1 : read();
}

This again, should produce less code - At least, it removes doublicated code...