mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -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:
@@ -97,7 +97,7 @@ QStringList Item::expandPath(const QString &path)
|
||||
int index = 0;
|
||||
while ((index = path.indexOf(Item::PathSeparator, index)) >= 0)
|
||||
{
|
||||
result << path.left(index);
|
||||
result << path.first(index);
|
||||
++index;
|
||||
}
|
||||
result << path;
|
||||
@@ -108,11 +108,11 @@ QStringList Item::expandPath(const QString &path)
|
||||
QString Item::parentPath(const QString &path)
|
||||
{
|
||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
||||
return (pos >= 0) ? path.left(pos) : QString();
|
||||
return (pos >= 0) ? path.first(pos) : QString();
|
||||
}
|
||||
|
||||
QString Item::relativeName(const QString &path)
|
||||
{
|
||||
int pos;
|
||||
return ((pos = path.lastIndexOf(Item::PathSeparator)) >= 0 ? path.right(path.size() - (pos + 1)) : path);
|
||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
||||
return (pos >= 0) ? path.sliced(pos + 1) : path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user