mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
[Rules] balanceParentheses(): Always use String.reserve when changing string
This commit is contained in:
@@ -1323,12 +1323,14 @@ int balanceParentheses(String& string) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (left != right) {
|
||||
string.reserve(string.length() + abs(right - left)); // Re-allocate max. once
|
||||
}
|
||||
if (left > right) {
|
||||
for (int i = 0; i < left - right; i++) {
|
||||
string += ')';
|
||||
}
|
||||
} else if (right > left) {
|
||||
string.reserve(string.length() + (right - left)); // Re-allocate max. once
|
||||
for (int i = 0; i < right - left; i++) {
|
||||
string = String(F("(")) + string; // This is quite 'expensive'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user