[Pkg-owncloud-commits] [owncloud-client] 71/78: Performance: Don't redundantly add the same exclude files #4967 (#4988)
Sandro Knauß
hefee-guest at moszumanska.debian.org
Fri Jun 24 16:29:45 UTC 2016
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 8b147017bb7fd266edf7140c3ce11b1e8c123f3f
Author: ckamm <mail at ckamm.de>
Date: Mon Jun 20 15:14:13 2016 +0200
Performance: Don't redundantly add the same exclude files #4967 (#4988)
Excludes: Don't redundantly add the same exclude files #4967, Never accept duplicate exclude patterns #4967
---
csync/src/csync_exclude.c | 12 ++++++++++++
src/gui/folder.cpp | 4 ++++
src/libsync/excludedfiles.cpp | 2 +-
src/libsync/excludedfiles.h | 5 +++--
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/csync/src/csync_exclude.c b/csync/src/csync_exclude.c
index fe999ed..bad25f8 100644
--- a/csync/src/csync_exclude.c
+++ b/csync/src/csync_exclude.c
@@ -44,6 +44,18 @@
static
#endif
int _csync_exclude_add(c_strlist_t **inList, const char *string) {
+ size_t i = 0;
+
+ // We never want duplicates, so check whether the string is already
+ // in the list first.
+ if (*inList) {
+ for (i = 0; i < (*inList)->count; ++i) {
+ char *pattern = (*inList)->vector[i];
+ if (c_streq(pattern, string)) {
+ return 0;
+ }
+ }
+ }
return c_strlist_add_grow(inList, string);
}
diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp
index 3b36ca4..1b5cdad 100644
--- a/src/gui/folder.cpp
+++ b/src/gui/folder.cpp
@@ -695,6 +695,10 @@ void Folder::wipe()
bool Folder::setIgnoredFiles()
{
+ // Note: Doing this on each sync run and on Folder construction is
+ // unnecessary, because _engine->excludedFiles() persists between
+ // sync runs. This is not a big problem because ExcludedFiles maintains
+ // a QSet of files to load.
ConfigFile cfg;
QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
if( QFile::exists(systemList) ) {
diff --git a/src/libsync/excludedfiles.cpp b/src/libsync/excludedfiles.cpp
index d4eed06..b2839d0 100644
--- a/src/libsync/excludedfiles.cpp
+++ b/src/libsync/excludedfiles.cpp
@@ -42,7 +42,7 @@ ExcludedFiles& ExcludedFiles::instance()
void ExcludedFiles::addExcludeFilePath(const QString& path)
{
- _excludeFiles.append(path);
+ _excludeFiles.insert(path);
}
bool ExcludedFiles::reloadExcludes()
diff --git a/src/libsync/excludedfiles.h b/src/libsync/excludedfiles.h
index 5e47f7c..75895a3 100644
--- a/src/libsync/excludedfiles.h
+++ b/src/libsync/excludedfiles.h
@@ -16,7 +16,8 @@
#include "owncloudlib.h"
#include <QObject>
-#include <QStringList>
+#include <QSet>
+#include <QString>
extern "C" {
#include "std/c_string.h"
@@ -66,7 +67,7 @@ private:
// This is a pointer to the csync exclude list, its is owned by this class
// but the pointer can be in a csync_context so that it can itself also query the list.
c_strlist_t** _excludesPtr;
- QStringList _excludeFiles;
+ QSet<QString> _excludeFiles;
};
} // namespace OCC
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list