From 36075257c2433d4427882cac9126abb68f11d97c Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Mon, 20 Jan 2020 14:29:16 +0100 Subject: [PATCH] WString explicit converters to reduce Flash size (#3497) * WString explicit converters to reduce Flash size This is a port from the same patch for ESP8266: https://github.com/esp8266/Arduino/pull/6759/files --- cores/esp32/WString.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cores/esp32/WString.h b/cores/esp32/WString.h index 38bd116f..9111d9aa 100644 --- a/cores/esp32/WString.h +++ b/cores/esp32/WString.h @@ -203,8 +203,20 @@ class String { unsigned char equalsIgnoreCase(const String &s) const; unsigned char equalsConstantTime(const String &s) const; unsigned char startsWith(const String &prefix) const; + unsigned char startsWith(const char *prefix) const { + return this->startsWith(String(prefix)); + } + unsigned char startsWith(const __FlashStringHelper *prefix) const { + return this->startsWith(String(prefix)); + } unsigned char startsWith(const String &prefix, unsigned int offset) const; unsigned char endsWith(const String &suffix) const; + unsigned char endsWith(const char *suffix) const { + return this->endsWith(String(suffix)); + } + unsigned char endsWith(const __FlashStringHelper * suffix) const { + return this->endsWith(String(suffix)); + } // character access char charAt(unsigned int index) const; @@ -238,7 +250,22 @@ class String { // modification void replace(char find, char replace); - void replace(const String& find, const String& replace); + void replace(const String &find, const String &replace); + void replace(const char *find, const String &replace) { + this->replace(String(find), replace); + } + void replace(const __FlashStringHelper *find, const String &replace) { + this->replace(String(find), replace); + } + void replace(const char *find, const char *replace) { + this->replace(String(find), String(replace)); + } + void replace(const __FlashStringHelper *find, const char *replace) { + this->replace(String(find), String(replace)); + } + void replace(const __FlashStringHelper *find, const __FlashStringHelper *replace) { + this->replace(String(find), String(replace)); + } void remove(unsigned int index); void remove(unsigned int index, unsigned int count); void toLowerCase(void);