From: Peter Penz Date: Thu, 25 Mar 2010 07:02:02 +0000 (+0000) Subject: Remove the redundant m_versionInfoKeys member, just iterate the hash table instead X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/16f1ade812160c5ceb5b690c57a7a9d1bf91352f Remove the redundant m_versionInfoKeys member, just iterate the hash table instead svn path=/trunk/KDE/kdebase/apps/; revision=1107255 --- diff --git a/src/versioncontrol/fileviewsvnplugin.cpp b/src/versioncontrol/fileviewsvnplugin.cpp index f43f10e98..00bb373fe 100644 --- a/src/versioncontrol/fileviewsvnplugin.cpp +++ b/src/versioncontrol/fileviewsvnplugin.cpp @@ -45,7 +45,6 @@ FileViewSvnPlugin::FileViewSvnPlugin(QObject* parent, const QList& arg KVersionControlPlugin(parent), m_pendingOperation(false), m_versionInfoHash(), - m_versionInfoKeys(), m_updateAction(0), m_showLocalChangesAction(0), m_commitAction(0), @@ -103,7 +102,8 @@ bool FileViewSvnPlugin::beginRetrieval(const QString& directory) { Q_ASSERT(directory.endsWith('/')); - // clear all entries for this directory + // Clear all entries for this directory including the entries + // for sub directories QMutableHashIterator it(m_versionInfoHash); while (it.hasNext()) { it.next(); @@ -136,16 +136,21 @@ bool FileViewSvnPlugin::beginRetrieval(const QString& directory) break; } - int pos = filePath.indexOf('/'); - const int length = filePath.length() - pos - 1; - filePath = filePath.mid(pos, length); - if (!filePath.isEmpty()) { - m_versionInfoHash.insert(filePath, state); + // Only values with a different state as 'NormalVersion' + // are added to the hash table. If a value is not in the + // hash table, it is automatically defined as 'NormalVersion' + // (see FileViewSvnPlugin::versionState()). + if (state != NormalVersion) { + int pos = filePath.indexOf('/'); + const int length = filePath.length() - pos - 1; + filePath = filePath.mid(pos, length); + if (!filePath.isEmpty()) { + m_versionInfoHash.insert(filePath, state); + } } } } - m_versionInfoKeys = m_versionInfoHash.keys(); return true; } @@ -169,13 +174,15 @@ KVersionControlPlugin::VersionState FileViewSvnPlugin::versionState(const KFileI // The item is a directory. Check whether an item listed by 'svn status' (= m_versionInfoHash) // is part of this directory. In this case a local modification should be indicated in the // directory already. - foreach (const QString& key, m_versionInfoKeys) { - if (key.startsWith(itemUrl)) { - const VersionState state = m_versionInfoHash.value(key); + QHash::const_iterator it = m_versionInfoHash.constBegin(); + while (it != m_versionInfoHash.constEnd()) { + if (it.key().startsWith(itemUrl)) { + const VersionState state = m_versionInfoHash.value(it.key()); if (state == LocallyModifiedVersion) { return LocallyModifiedVersion; } } + ++it; } return NormalVersion; diff --git a/src/versioncontrol/fileviewsvnplugin.h b/src/versioncontrol/fileviewsvnplugin.h index e94c3ebcb..854652329 100644 --- a/src/versioncontrol/fileviewsvnplugin.h +++ b/src/versioncontrol/fileviewsvnplugin.h @@ -74,7 +74,6 @@ private: private: bool m_pendingOperation; QHash m_versionInfoHash; - QList m_versionInfoKeys; // cache for accessing the keys of the hash QAction* m_updateAction; QAction* m_showLocalChangesAction;