Skip to content

Commit 27aa29b

Browse files
authored
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
1 parent cec3fca commit 27aa29b

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

Diff for: cores/esp32/WString.h

+29-2
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,21 @@ class String {
203203
unsigned char equalsIgnoreCase(const String &s) const;
204204
unsigned char equalsConstantTime(const String &s) const;
205205
unsigned char startsWith(const String &prefix) const;
206+
unsigned char startsWith(const char *prefix) const {
207+
return this->startsWith(String(prefix));
208+
 }
209+
unsigned char startsWith(const __FlashStringHelper * prefix) const {
210+
return this->startsWith(String(prefix));
211+
 }
206212
unsigned char startsWith(const String &prefix, unsigned int offset) const;
207213
unsigned char endsWith(const String &suffix) const;
208-
214+
unsigned char endsWith(const char *suffix) const {
215+
return this->endsWith(String(suffix));
216+
 }
217+
unsigned char endsWith(const __FlashStringHelper *suffix) const {
218+
return this->endsWith(String(suffix));
219+
 }
220+
209221
// character access
210222
char charAt(unsigned int index) const;
211223
void setCharAt(unsigned int index, char c);
@@ -238,7 +250,22 @@ class String {
238250

239251
// modification
240252
void replace(char find, char replace);
241-
void replace(const String& find, const String& replace);
253+
void replace(const String &find, const String &replace);
254+
void replace(const char *find, const String &replace) {
255+
this->replace(String(find), replace);
256+
 }
257+
void replace(const __FlashStringHelper *find, const String &replace) {
258+
this->replace(String(find), replace);
259+
 }
260+
void replace(const char *find, const char *replace) {
261+
this->replace(String(find), String(replace));
262+
 }
263+
void replace(const __FlashStringHelper *find, const char *replace) {
264+
this->replace(String(find), String(replace));
265+
 }
266+
void replace(const __FlashStringHelper *find, const __FlashStringHelper *replace) {
267+
this->replace(String(find), String(replace));
268+
 }
242269
void remove(unsigned int index);
243270
void remove(unsigned int index, unsigned int count);
244271
void toLowerCase(void);

0 commit comments

Comments
 (0)