mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-10 08:05:58 +01:00
optimize removing trailing spaces
This commit is contained in:
parent
0a08830375
commit
174b593438
1 changed files with 8 additions and 4 deletions
|
@ -120,14 +120,18 @@ void scaleBox(wlr_box* box, float scale) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string removeBeginEndSpacesTabs(std::string str) {
|
std::string removeBeginEndSpacesTabs(std::string str) {
|
||||||
while (str[0] == ' ' || str[0] == '\t') {
|
int countBefore = 0;
|
||||||
str = str.substr(1);
|
while (str[countBefore] == ' ' || str[countBefore] == '\t') {
|
||||||
|
countBefore++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (str.length() != 0 && (str[str.length() - 1] == ' ' || str[str.length() - 1] == '\t')) {
|
int countAfter = 0;
|
||||||
str = str.substr(0, str.length() - 1);
|
while (str.length() != 0 && (str[str.length() - countAfter - 1] == ' ' || str[str.length() - 1 - countAfter] == '\t')) {
|
||||||
|
countAfter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str = str.substr(countBefore, str.length() - countBefore - countAfter);
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue