Skip to content

Commit 432c648

Browse files
Simplify String::concat(char)
Now concat(const char*, unsigned int) no longer requires a nul-terminated string, we can simplify the concat(char) method to just pass the address of the single character instead of having to create buffer with nul-termination.
1 parent bf438eb commit 432c648

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

hardware/arduino/avr/cores/arduino/WString.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,7 @@ unsigned char String::concat(const char *cstr)
279279

280280
unsigned char String::concat(char c)
281281
{
282-
char buf[2];
283-
buf[0] = c;
284-
buf[1] = 0;
285-
return concat(buf, 1);
282+
return concat(&c, 1);
286283
}
287284

288285
unsigned char String::concat(unsigned char num)

hardware/arduino/sam/cores/arduino/WString.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,7 @@ unsigned char String::concat(const char *cstr)
281281

282282
unsigned char String::concat(char c)
283283
{
284-
char buf[2];
285-
buf[0] = c;
286-
buf[1] = 0;
287-
return concat(buf, 1);
284+
return concat(&c, 1);
288285
}
289286

290287
unsigned char String::concat(unsigned char num)

0 commit comments

Comments
 (0)