mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Speed up empty String creation slightly (#6573)
As @dirkmuller found out in #6568, there is a difference in code executed between `String str(nullptr)` and `String str("")`, but in the end the actual object is identical. It's a few bytes of code, but every little bit counts. Update the default `String()` constructor to use `nullptr` and not `""`. This will remove a constant literal load and the execution of the String::copy method and strlen().
This commit is contained in:
parent
1d26b28225
commit
1aeea124b3
@ -53,7 +53,7 @@ class String {
|
||||
// if the initial value is null or invalid, or if memory allocation
|
||||
// fails, the string will be marked as invalid (i.e. "if (s)" will
|
||||
// be false).
|
||||
String(const char *cstr = "");
|
||||
String(const char *cstr = nullptr);
|
||||
String(const String &str);
|
||||
String(const __FlashStringHelper *str);
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
|
Loading…
x
Reference in New Issue
Block a user