From b915461519f1a4b7da8920203529e315eee39323 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Fri, 29 Jan 2010 13:12:40 +0100 Subject: optimize QDir::cd() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already create a file engine for testing if dir exists. We can also use it as source for current QDir. Merge-request: 445 Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3a04920..eb02e6c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -929,14 +929,13 @@ bool QDir::cd(const QString &dirName) } } } - { - QFileInfo fi(newPath); - if (!(fi.exists() && fi.isDir())) - return false; - } - d->setPath(newPath); - refresh(); + QDir dir(*this); + dir.setPath(newPath); + if (!dir.exists()) + return false; + + *this = dir; return true; } -- cgit v0.12