Skip to content

Commit 94e7274

Browse files
committed
Refactor for fewer indirect calls.
1 parent 56d2ebe commit 94e7274

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: cores/esp32/HardwareSerial.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ int HardwareSerial::read(void)
137137
// the buffer is NOT null terminated.
138138
size_t HardwareSerial::read(uint8_t *buffer, size_t size)
139139
{
140+
size_t avail = available();
141+
if (size < avail) {
142+
avail = size;
143+
}
140144
size_t count = 0;
141-
while(count < size) {
142-
int c = read();
143-
if(c < 0) {
144-
break;
145-
}
146-
*buffer++ = (char) c;
145+
while(count < avail) {
146+
*buffer++ = uartRead(_uart);
147147
count++;
148148
}
149149
return count;

0 commit comments

Comments
 (0)