From 1aeea124b358c3dc63e1c6fb96376695cf24840b Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 30 Sep 2019 22:35:23 -0700 Subject: [PATCH] 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(). --- cores/esp8266/WString.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp8266/WString.h b/cores/esp8266/WString.h index 558d1da85..8c970abf1 100644 --- a/cores/esp8266/WString.h +++ b/cores/esp8266/WString.h @@ -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__