mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 14:08:03 -06:00
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:
@@ -39,7 +39,11 @@ PeerAddress PeerAddress::parse(const QStringView address)
|
||||
if (address.startsWith(u'[') && address.contains(u"]:"))
|
||||
{ // IPv6
|
||||
ipPort = address.split(u"]:");
|
||||
ipPort[0] = ipPort[0].mid(1); // chop '['
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
ipPort[0].slice(1); // chop '['
|
||||
#else
|
||||
ipPort[0] = ipPort[0].sliced(1); // chop '['
|
||||
#endif
|
||||
}
|
||||
else if (address.contains(u':'))
|
||||
{ // IPv4
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user