diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2010-01-26 16:26:48 (GMT) |
---|---|---|
committer | João Abecasis <joao@trolltech.com> | 2010-01-26 16:26:48 (GMT) |
commit | d48fdf76f721b97e427073c665102e1b42398883 (patch) | |
tree | 5c6518d49891d98479b9d07b688e4474e1e8f502 /src/corelib/io | |
parent | 3a5eb87965b60a3e249a16dc48cb06f4759dfb1b (diff) | |
download | Qt-d48fdf76f721b97e427073c665102e1b42398883.zip Qt-d48fdf76f721b97e427073c665102e1b42398883.tar.gz Qt-d48fdf76f721b97e427073c665102e1b42398883.tar.bz2 |
Simplify QFileInfoPrivate::getFileTime
remove repeated code; improve readability
Merge-request: 446
Reviewed-by: João Abecasis <joao@trolltech.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfileinfo.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 2260036..6616066 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -204,25 +204,18 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) { if (!data->cache_enabled) data->clearFlags(); - if(request == QAbstractFileEngine::CreationTime) { - if(data->getCachedFlag(CachedCTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedCTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); + uint cf; + if (request == QAbstractFileEngine::CreationTime) + cf = CachedCTime; + else if (request == QAbstractFileEngine::ModificationTime) + cf = CachedMTime; + else + cf = CachedATime; + if (!data->getCachedFlag(cf)) { + data->fileTimes[request] = data->fileEngine->fileTime(request); + data->setCachedFlag(cf); } - if(request == QAbstractFileEngine::ModificationTime) { - if(data->getCachedFlag(CachedMTime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedMTime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - if(request == QAbstractFileEngine::AccessTime) { - if(data->getCachedFlag(CachedATime)) - return data->fileTimes[request]; - data->setCachedFlag(CachedATime); - return (data->fileTimes[request] = data->fileEngine->fileTime(request)); - } - return data->fileTimes[0]; //cannot really happen + return data->fileTimes[request]; } //************* QFileInfo |