mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
avoid temporary and remove always true case in QDir::cleanPath()
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
62da531ca4
commit
996edf7e69
1 changed files with 3 additions and 7 deletions
|
@ -1738,17 +1738,13 @@ QString QDir::cleanPath(const QString &path)
|
|||
{
|
||||
if (path.isEmpty())
|
||||
return path;
|
||||
QString name = path;
|
||||
QChar dir_separator = separator();
|
||||
if (dir_separator != QLatin1Char('/'))
|
||||
name.replace(dir_separator, QLatin1Char('/'));
|
||||
|
||||
int used = 0, levels = 0;
|
||||
const int len = name.length();
|
||||
const int len = path.length();
|
||||
QVarLengthArray<QChar> outVector(len);
|
||||
QChar *out = outVector.data();
|
||||
|
||||
const QChar *p = name.unicode();
|
||||
const QChar *p = path.unicode();
|
||||
for (int i = 0, last = -1, iwrite = 0; i < len; ++i) {
|
||||
if (p[i] == QLatin1Char('/')) {
|
||||
while (i+1 < len && p[i+1] == QLatin1Char('/')) {
|
||||
|
@ -1836,7 +1832,7 @@ QString QDir::cleanPath(const QString &path)
|
|||
used++;
|
||||
}
|
||||
|
||||
QString ret = (used == len ? name : QString(out, used));
|
||||
QString ret = (used == len ? path : QString(out, used));
|
||||
// Strip away last slash except for root directories
|
||||
if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) {
|
||||
ret.chop(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue