Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass string objects by reference #5378

Merged
merged 1 commit into from
Nov 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cores/esp8266/MD5Builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class MD5Builder {
void add(const uint8_t * data, const uint16_t len);
void add(const char * data){ add((const uint8_t*)data, strlen(data)); }
void add(char * data){ add((const char*)data); }
void add(const String data){ add(data.c_str()); }
void add(const String& data){ add(data.c_str()); }
void addHexString(const char * data);
void addHexString(char * data){ addHexString((const char*)data); }
void addHexString(const String data){ addHexString(data.c_str()); }
void addHexString(const String& data){ addHexString(data.c_str()); }
bool addStream(Stream & stream, const size_t maxLen);
void calculate(void);
void getBytes(uint8_t * output);
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ bool ESP8266WiFiSTAClass::hostname(const char* aHostname) {
* @param aHostname max length:32
* @return ok
*/
bool ESP8266WiFiSTAClass::hostname(String aHostname) {
bool ESP8266WiFiSTAClass::hostname(const String& aHostname) {
return hostname((char*) aHostname.c_str());
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ESP8266WiFiSTAClass {
String hostname();
bool hostname(char* aHostname);
bool hostname(const char* aHostname);
bool hostname(String aHostname);
bool hostname(const String& aHostname);

// STA WiFi info
wl_status_t status();
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int WiFiClient::connect(const char* host, uint16_t port)
return 0;
}

int WiFiClient::connect(const String host, uint16_t port)
int WiFiClient::connect(const String& host, uint16_t port)
{
return connect(host.c_str(), port);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WiFiClient : public Client, public SList<WiFiClient> {
uint8_t status();
virtual int connect(IPAddress ip, uint16_t port);
virtual int connect(const char *host, uint16_t port);
virtual int connect(const String host, uint16_t port);
virtual int connect(const String& host, uint16_t port);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
virtual size_t write_P(PGM_P buf, size_t size);
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClientSecureAxTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int WiFiClientSecure::connect(const char* name, uint16_t port)
return _connectSSL(name);
}

int WiFiClientSecure::connect(const String host, uint16_t port)
int WiFiClientSecure::connect(const String& host, uint16_t port)
{
return connect(host.c_str(), port);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiClientSecureAxTLS.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class WiFiClientSecure : public WiFiClient {
~WiFiClientSecure() override;

int connect(IPAddress ip, uint16_t port) override;
int connect(const String host, uint16_t port) override;
int connect(const String& host, uint16_t port) override;
int connect(const char* name, uint16_t port) override;

bool verify(const char* fingerprint, const char* domain_name);
Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int WiFiClientSecure::connect(const char* name, uint16_t port) {
return _connectSSL(name);
}

int WiFiClientSecure::connect(const String host, uint16_t port) {
int WiFiClientSecure::connect(const String& host, uint16_t port) {
return connect(host.c_str(), port);
}

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

bool WiFiClientSecure::probeMaxFragmentLength(const String host, uint16_t port, uint16_t len) {
bool WiFiClientSecure::probeMaxFragmentLength(const String& host, uint16_t port, uint16_t len) {
return WiFiClientSecure::probeMaxFragmentLength(host.c_str(), port, len);
}

Expand Down
4 changes: 2 additions & 2 deletions libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WiFiClientSecure : public WiFiClient {
~WiFiClientSecure() override;

int connect(IPAddress ip, uint16_t port) override;
int connect(const String host, uint16_t port) override;
int connect(const String& host, uint16_t port) override;
int connect(const char* name, uint16_t port) override;

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

// AXTLS compatible wrappers
// Cannot implement this mode, we need FP before we can connect: bool verify(const char* fingerprint, const char* domain_name)
Expand Down
6 changes: 3 additions & 3 deletions libraries/ESP8266mDNS/ESP8266mDNS.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ class MDNSResponder {
void addService(const char *service, const char *proto, uint16_t port){
addService((char *)service, (char *)proto, port);
}
void addService(String service, String proto, uint16_t port){
void addService(const String& service, const String& proto, uint16_t port){
addService(service.c_str(), proto.c_str(), port);
}

bool addServiceTxt(char *name, char *proto, char * key, char * value);
bool addServiceTxt(const char *name, const char *proto, const char *key,const char * value){
return addServiceTxt((char *)name, (char *)proto, (char *)key, (char *)value);
}
bool addServiceTxt(String name, String proto, String key, String value){
bool addServiceTxt(const String& name, const String& proto, const String& key, const String& value){
return addServiceTxt(name.c_str(), proto.c_str(), key.c_str(), value.c_str());
}

int queryService(char *service, char *proto);
int queryService(const char *service, const char *proto){
return queryService((char *)service, (char *)proto);
}
int queryService(String service, String proto){
int queryService(const String& service, const String& proto){
return queryService(service.c_str(), proto.c_str());
}
String hostname(int idx);
Expand Down