Using emptyString constant instead of String()

This commit is contained in:
Mathieu Carbou
2024-08-08 09:46:57 +02:00
parent 40a2fd71bf
commit 843f07334a
4 changed files with 20 additions and 20 deletions

View File

@@ -293,11 +293,11 @@ class AsyncWebServerRequest {
void redirect(const String& url) { return redirect(url.c_str()); };
void send(AsyncWebServerResponse* response);
void send(int code, const String& contentType = String(), const String& content = String());
void send(int code, const String& contentType = emptyString, const String& content = emptyString);
void send(int code, const String& contentType, const uint8_t* content, size_t len, AwsTemplateProcessor callback = nullptr);
void send(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback = nullptr);
void send(FS& fs, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
void send(File content, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
void send(FS& fs, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
void send(File content, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
void send(Stream& stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
void send(const String& contentType, size_t len, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);
void sendChunked(const String& contentType, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);
@@ -311,11 +311,11 @@ class AsyncWebServerRequest {
send(code, contentType, content, callback);
}
AsyncWebServerResponse* beginResponse(int code, const String& contentType = String(), const String& content = String());
AsyncWebServerResponse* beginResponse(int code, const String& contentType = emptyString, const String& content = emptyString);
AsyncWebServerResponse* beginResponse(int code, const String& contentType, const uint8_t* content, size_t len, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(FS& fs, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(File content, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(FS& fs, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(File content, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(Stream& stream, const String& contentType, size_t len, AwsTemplateProcessor callback = nullptr);
AsyncWebServerResponse* beginResponse(const String& contentType, size_t len, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);
AsyncWebServerResponse* beginChunkedResponse(const String& contentType, AwsResponseFiller callback, AwsTemplateProcessor templateCallback = nullptr);

View File

@@ -274,7 +274,7 @@ bool AsyncWebServerRequest::_parseReqHead() {
if (!_temp.startsWith(T_HTTP_1_0))
_version = 1;
_temp = String();
_temp = emptyString;
return true;
}
@@ -327,7 +327,7 @@ bool AsyncWebServerRequest::_parseReqHeader() {
_temp.clear();
#else
// Ancient PRI core does not have String::clear() method 8-()
_temp = String();
_temp = emptyString;
#endif
return true;
}
@@ -348,7 +348,7 @@ void AsyncWebServerRequest::_parsePlainPostChar(uint8_t data) {
_temp.clear();
#else
// Ancient PRI core does not have String::clear() method 8-()
_temp = String();
_temp = emptyString;
#endif
}
}
@@ -390,10 +390,10 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) {
if (!_parsedLength) {
_multiParseState = EXPECT_BOUNDARY;
_temp = String();
_itemName = String();
_itemFilename = String();
_itemType = String();
_temp = emptyString;
_itemName = emptyString;
_itemFilename = emptyString;
_itemType = emptyString;
}
if (_multiParseState == WAIT_FOR_RETURN1) {
@@ -450,13 +450,13 @@ void AsyncWebServerRequest::_parseMultipartPostByte(uint8_t data, bool last) {
_itemIsFile = true;
}
}
_temp = String();
_temp = emptyString;
} else {
_multiParseState = WAIT_FOR_RETURN1;
// value starts from here
_itemSize = 0;
_itemStartIndex = _parsedLength;
_itemValue = String();
_itemValue = emptyString;
if (_itemIsFile) {
if (_itemBuffer)
free(_itemBuffer);

View File

@@ -36,7 +36,7 @@ class AsyncBasicResponse : public AsyncWebServerResponse {
String _content;
public:
AsyncBasicResponse(int code, const String& contentType = String(), const String& content = String());
AsyncBasicResponse(int code, const String& contentType = emptyString, const String& content = emptyString);
void _respond(AsyncWebServerRequest* request);
size_t _ack(AsyncWebServerRequest* request, size_t len, uint32_t time);
bool _sourceValid() const { return true; }
@@ -79,8 +79,8 @@ class AsyncFileResponse : public AsyncAbstractResponse {
void _setContentType(const String& path);
public:
AsyncFileResponse(FS& fs, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncFileResponse(File content, const String& path, const String& contentType = String(), bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncFileResponse(FS& fs, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
AsyncFileResponse(File content, const String& path, const String& contentType = emptyString, bool download = false, AwsTemplateProcessor callback = nullptr);
~AsyncFileResponse();
bool _sourceValid() const { return !!(_content); }
virtual size_t _fillBuffer(uint8_t* buf, size_t maxLen) override;

View File

@@ -353,7 +353,7 @@ size_t AsyncBasicResponse::_ack(AsyncWebServerRequest* request, size_t len, uint
// we can fit in this packet
if (space > available) {
_writtenLength += request->client()->write(_content.c_str(), available);
_content = String();
_content = emptyString;
_state = RESPONSE_WAIT_ACK;
return available;
}
@@ -465,7 +465,7 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest* request, size_t len, u
}
if (headLen) {
_head = String();
_head = emptyString;
}
if (outLen) {