Use slice method where applicable

These code segments already have its boundary checked and can thus be faster.

PR #22411.
This commit is contained in:
Chocobo1 2025-03-15 14:58:59 +08:00 committed by GitHub
parent d174bc75e4
commit 5a4b3b25d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 113 additions and 63 deletions

View file

@ -365,7 +365,7 @@ QString Session::subcategoryName(const QString &category)
{
const int sepIndex = category.lastIndexOf(u'/');
if (sepIndex >= 0)
return category.mid(sepIndex + 1);
return category.sliced(sepIndex + 1);
return category;
}
@ -374,7 +374,7 @@ QString Session::parentCategoryName(const QString &category)
{
const int sepIndex = category.lastIndexOf(u'/');
if (sepIndex >= 0)
return category.left(sepIndex);
return category.first(sepIndex);
return {};
}
@ -385,7 +385,7 @@ QStringList Session::expandCategory(const QString &category)
int index = 0;
while ((index = category.indexOf(u'/', index)) >= 0)
{
result << category.left(index);
result << category.first(index);
++index;
}
result << category;