summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2009-08-11 16:11:42 (GMT)
committerJoerg Bornemann <joerg.bornemann@trolltech.com>2009-08-11 16:26:27 (GMT)
commit085d1cb57d240e5335517ccd08da699d4faeed6a (patch)
treecf006b751f72547e8ad7ffc3e7832249930c7445 /src
parenta7e9efcb96a93f23636e8bc98bb89b705a82cbf4 (diff)
downloadQt-085d1cb57d240e5335517ccd08da699d4faeed6a.zip
Qt-085d1cb57d240e5335517ccd08da699d4faeed6a.tar.gz
Qt-085d1cb57d240e5335517ccd08da699d4faeed6a.tar.bz2
minor optimizations
-in most cases GetFullPathName returns string with at least path.size() chars; -". " isn't valid path; ". " isn't valid path too...should we to pay more? Merge-request: 1176 Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index a6c2c17..3a5e9f4 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -349,7 +349,7 @@ static QString nativeAbsoluteFilePathCore(const QString &path)
{
QString ret;
#if !defined(Q_OS_WINCE)
- QVarLengthArray<wchar_t, MAX_PATH> buf(MAX_PATH);
+ QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
wchar_t *fileName = 0;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
if (retLen > (DWORD)buf.size()) {
@@ -375,15 +375,8 @@ static QString nativeAbsoluteFilePath(const QString &path)
// (which is an invalid filename) this function will strip the space off and viola,
// the file is later reported as existing. Therefore, we re-add the whitespace that
// was at the end of path in order to keep the filename invalid.
- int i = path.size() - 1;
- while (i >= 0 && path.at(i) == QLatin1Char(' ')) --i;
- int extraws = path.size() - 1 - i;
- if (extraws >= 0) {
- while (extraws) {
- absPath.append(QLatin1Char(' '));
- --extraws;
- }
- }
+ if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' '))
+ absPath.append(QLatin1Char(' '));
return absPath;
}