Skip to content

Commit 3607525

Browse files
everslickme-no-dev
authored andcommitted
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
1 parent 7de1717 commit 3607525

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

Diff for: cores/esp32/WString.h

+28-1
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,20 @@ 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;
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+
}
208220

209221
// character access
210222
char charAt(unsigned int index) const;
@@ -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)