]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Remove the redundant m_versionInfoKeys member, just iterate the hash table instead
authorPeter Penz <peter.penz19@gmail.com>
Thu, 25 Mar 2010 07:02:02 +0000 (07:02 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 25 Mar 2010 07:02:02 +0000 (07:02 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=1107255

src/versioncontrol/fileviewsvnplugin.cpp
src/versioncontrol/fileviewsvnplugin.h

index f43f10e98d97c07000692ecd52aba7d0f5b456b0..00bb373fe0ed55c32b64ca23a2e64039dc47f937 100644 (file)
@@ -45,7 +45,6 @@ FileViewSvnPlugin::FileViewSvnPlugin(QObject* parent, const QList<QVariant>& 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<QString, VersionState> 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<QString, VersionState>::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;
index e94c3ebcb408b95a21cfecbb980613814dd97723..85465232930006c5376b1f89db7e9b7b7e9fb1c8 100644 (file)
@@ -74,7 +74,6 @@ private:
 private:
     bool m_pendingOperation;
     QHash<QString, VersionState> m_versionInfoHash;
-    QList<QString> m_versionInfoKeys; // cache for accessing the keys of the hash
 
     QAction* m_updateAction;
     QAction* m_showLocalChangesAction;