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

Further const correctness / String by reference passing cleanups (#6571)

There are actually several instances where we pass in read-only
parameters as pass-by-value, where in the case of String() that
is inefficient as it involves copy-constructor/temp string creations.

We can avoid that, similarly to single character string concatenations
done via string literals instead of char literals.
This commit is contained in:
Dirk Mueller
2019-10-31 16:02:40 +01:00
committed by david gauchard
parent ba971fe7e9
commit 8bc5a10d6d
11 changed files with 78 additions and 75 deletions

View File

@ -358,7 +358,7 @@ transmission_status_t ESP8266WiFiMesh::exchangeInfo(WiFiClient &currClient)
{
verboseModePrint("Transmitting"); // Not storing strings in flash (via F()) to avoid performance impacts when using the string.
currClient.print(getMessage() + "\r");
currClient.print(getMessage() + '\r');
yield();
if (!waitForClientTransmission(currClient, _stationModeTimeoutMs))
@ -582,11 +582,11 @@ void ESP8266WiFiMesh::attemptTransmission(const String &message, bool concluding
if(_verboseMode) // Avoid string generation if not required
{
verboseModePrint(String(F("AP acquired: ")) + currentSSID + String(F(", Ch:")) + String(currentWiFiChannel) + " ", false);
verboseModePrint(String(F("AP acquired: ")) + currentSSID + String(F(", Ch:")) + String(currentWiFiChannel) + ' ', false);
if(currentNetwork.networkIndex != NETWORK_INFO_DEFAULT_INT)
{
verboseModePrint("(" + String(WiFi.RSSI(currentNetwork.networkIndex)) + String(F("dBm) ")) +
verboseModePrint(String('(') + String(WiFi.RSSI(currentNetwork.networkIndex)) + String(F("dBm) ")) +
(WiFi.encryptionType(currentNetwork.networkIndex) == ENC_TYPE_NONE ? String(F("open")) : ""), false);
}
@ -662,7 +662,7 @@ void ESP8266WiFiMesh::acceptRequest()
if (_client.connected())
{
verboseModePrint("Responding"); // Not storing strings in flash (via F()) to avoid performance impacts when using the string.
_client.print(response + "\r");
_client.print(response + '\r');
_client.flush();
yield();
}