1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

ESP8266WebServer: reduce amount of string copying

This commit is contained in:
Ivan Grokhotkov
2015-06-24 23:58:53 +03:00
parent b029e78a67
commit e5fcdbd9e3
2 changed files with 11 additions and 11 deletions

View File

@ -115,7 +115,7 @@ void ESP8266WebServer::handleClient()
_handleRequest();
}
void ESP8266WebServer::sendHeader(String name, String value, bool first) {
void ESP8266WebServer::sendHeader(const String& name, const String& value, bool first) {
String headerLine = name;
headerLine += ": ";
headerLine += value;
@ -129,7 +129,7 @@ void ESP8266WebServer::sendHeader(String name, String value, bool first) {
}
}
void ESP8266WebServer::send(int code, const char* content_type, String content) {
void ESP8266WebServer::send(int code, const char* content_type, const String& content) {
String response = "HTTP/1.1 ";
response += String(code);
response += " ";
@ -155,15 +155,15 @@ void ESP8266WebServer::send(int code, const char* content_type, String content)
sendContent(response);
}
void ESP8266WebServer::send(int code, char* content_type, String content) {
void ESP8266WebServer::send(int code, char* content_type, const String& content) {
send(code, (const char*)content_type, content);
}
void ESP8266WebServer::send(int code, String content_type, String content) {
void ESP8266WebServer::send(int code, const String& content_type, const String& content) {
send(code, (const char*)content_type.c_str(), content);
}
void ESP8266WebServer::sendContent(String content) {
void ESP8266WebServer::sendContent(const String& content) {
size_t size_to_send = content.length();
size_t size_sent = 0;
while(size_to_send) {