Skip to content

Commit cd05bae

Browse files
dav1901devyte
authored andcommitted
Pass string objects by reference (#5378)
1 parent 72ad935 commit cd05bae

10 files changed

+15
-15
lines changed

cores/esp8266/MD5Builder.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class MD5Builder {
3434
void add(const uint8_t * data, const uint16_t len);
3535
void add(const char * data){ add((const uint8_t*)data, strlen(data)); }
3636
void add(char * data){ add((const char*)data); }
37-
void add(const String data){ add(data.c_str()); }
37+
void add(const String& data){ add(data.c_str()); }
3838
void addHexString(const char * data);
3939
void addHexString(char * data){ addHexString((const char*)data); }
40-
void addHexString(const String data){ addHexString(data.c_str()); }
40+
void addHexString(const String& data){ addHexString(data.c_str()); }
4141
bool addStream(Stream & stream, const size_t maxLen);
4242
void calculate(void);
4343
void getBytes(uint8_t * output);

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) {
487487
* @param aHostname max length:32
488488
* @return ok
489489
*/
490-
bool ESP8266WiFiSTAClass::hostname(String aHostname) {
490+
bool ESP8266WiFiSTAClass::hostname(const String& aHostname) {
491491
return hostname((char*) aHostname.c_str());
492492
}
493493

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ESP8266WiFiSTAClass {
7171
String hostname();
7272
bool hostname(char* aHostname);
7373
bool hostname(const char* aHostname);
74-
bool hostname(String aHostname);
74+
bool hostname(const String& aHostname);
7575

7676
// STA WiFi info
7777
wl_status_t status();

libraries/ESP8266WiFi/src/WiFiClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int WiFiClient::connect(const char* host, uint16_t port)
132132
return 0;
133133
}
134134

135-
int WiFiClient::connect(const String host, uint16_t port)
135+
int WiFiClient::connect(const String& host, uint16_t port)
136136
{
137137
return connect(host.c_str(), port);
138138
}

libraries/ESP8266WiFi/src/WiFiClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class WiFiClient : public Client, public SList<WiFiClient> {
5555
uint8_t status();
5656
virtual int connect(IPAddress ip, uint16_t port);
5757
virtual int connect(const char *host, uint16_t port);
58-
virtual int connect(const String host, uint16_t port);
58+
virtual int connect(const String& host, uint16_t port);
5959
virtual size_t write(uint8_t);
6060
virtual size_t write(const uint8_t *buf, size_t size);
6161
virtual size_t write_P(PGM_P buf, size_t size);

libraries/ESP8266WiFi/src/WiFiClientSecureAxTLS.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int WiFiClientSecure::connect(const char* name, uint16_t port)
116116
return _connectSSL(name);
117117
}
118118

119-
int WiFiClientSecure::connect(const String host, uint16_t port)
119+
int WiFiClientSecure::connect(const String& host, uint16_t port)
120120
{
121121
return connect(host.c_str(), port);
122122
}

libraries/ESP8266WiFi/src/WiFiClientSecureAxTLS.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class WiFiClientSecure : public WiFiClient {
3636
~WiFiClientSecure() override;
3737

3838
int connect(IPAddress ip, uint16_t port) override;
39-
int connect(const String host, uint16_t port) override;
39+
int connect(const String& host, uint16_t port) override;
4040
int connect(const char* name, uint16_t port) override;
4141

4242
bool verify(const char* fingerprint, const char* domain_name);

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ int WiFiClientSecure::connect(const char* name, uint16_t port) {
218218
return _connectSSL(name);
219219
}
220220

221-
int WiFiClientSecure::connect(const String host, uint16_t port) {
221+
int WiFiClientSecure::connect(const String& host, uint16_t port) {
222222
return connect(host.c_str(), port);
223223
}
224224

@@ -1108,7 +1108,7 @@ bool WiFiClientSecure::probeMaxFragmentLength(const char* name, uint16_t port, u
11081108
return WiFiClientSecure::probeMaxFragmentLength(remote_addr, port, len);
11091109
}
11101110

1111-
bool WiFiClientSecure::probeMaxFragmentLength(const String host, uint16_t port, uint16_t len) {
1111+
bool WiFiClientSecure::probeMaxFragmentLength(const String& host, uint16_t port, uint16_t len) {
11121112
return WiFiClientSecure::probeMaxFragmentLength(host.c_str(), port, len);
11131113
}
11141114

libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WiFiClientSecure : public WiFiClient {
3737
~WiFiClientSecure() override;
3838

3939
int connect(IPAddress ip, uint16_t port) override;
40-
int connect(const String host, uint16_t port) override;
40+
int connect(const String& host, uint16_t port) override;
4141
int connect(const char* name, uint16_t port) override;
4242

4343
uint8_t connected() override;
@@ -119,7 +119,7 @@ class WiFiClientSecure : public WiFiClient {
119119
// Check for Maximum Fragment Length support for given len
120120
static bool probeMaxFragmentLength(IPAddress ip, uint16_t port, uint16_t len);
121121
static bool probeMaxFragmentLength(const char *hostname, uint16_t port, uint16_t len);
122-
static bool probeMaxFragmentLength(const String host, uint16_t port, uint16_t len);
122+
static bool probeMaxFragmentLength(const String& host, uint16_t port, uint16_t len);
123123

124124
// AXTLS compatible wrappers
125125
// Cannot implement this mode, we need FP before we can connect: bool verify(const char* fingerprint, const char* domain_name)

libraries/ESP8266mDNS/ESP8266mDNS.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,23 @@ class MDNSResponder {
7676
void addService(const char *service, const char *proto, uint16_t port){
7777
addService((char *)service, (char *)proto, port);
7878
}
79-
void addService(String service, String proto, uint16_t port){
79+
void addService(const String& service, const String& proto, uint16_t port){
8080
addService(service.c_str(), proto.c_str(), port);
8181
}
8282

8383
bool addServiceTxt(char *name, char *proto, char * key, char * value);
8484
bool addServiceTxt(const char *name, const char *proto, const char *key,const char * value){
8585
return addServiceTxt((char *)name, (char *)proto, (char *)key, (char *)value);
8686
}
87-
bool addServiceTxt(String name, String proto, String key, String value){
87+
bool addServiceTxt(const String& name, const String& proto, const String& key, const String& value){
8888
return addServiceTxt(name.c_str(), proto.c_str(), key.c_str(), value.c_str());
8989
}
9090

9191
int queryService(char *service, char *proto);
9292
int queryService(const char *service, const char *proto){
9393
return queryService((char *)service, (char *)proto);
9494
}
95-
int queryService(String service, String proto){
95+
int queryService(const String& service, const String& proto){
9696
return queryService(service.c_str(), proto.c_str());
9797
}
9898
String hostname(int idx);

0 commit comments

Comments
 (0)