csync: use a unordered_map for the FileMap
authorOlivier Goffart <ogoffart@woboq.com>
Sat, 23 Sep 2017 11:49:30 +0000 (13:49 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 5 Oct 2017 20:01:36 +0000 (22:01 +0200)
Saves more than 10% of csync_update on LargeSyncBench

src/csync/csync_private.h

index 9167a53a4e14777040c389f8f632dca511350b12..f3398f7a7bccfc38ff3394b5dd6944e7b2d7619d 100644 (file)
@@ -32,7 +32,8 @@
 #ifndef _CSYNC_PRIVATE_H
 #define _CSYNC_PRIVATE_H
 
-#include <map>
+#include <unordered_map>
+#include <QHash>
 #include <stdint.h>
 #include <stdbool.h>
 #include <sqlite3.h>
@@ -70,7 +71,8 @@ enum csync_replica_e {
  * @brief csync public structure
  */
 struct OCSYNC_EXPORT csync_s {
-  class FileMap : public std::map<QByteArray, std::unique_ptr<csync_file_stat_t>> {
+  struct FileMapHash { uint operator()(const QByteArray &a) const { return qHash(a); } };
+  class FileMap : public std::unordered_map<QByteArray, std::unique_ptr<csync_file_stat_t>, FileMapHash> {
   public:
       csync_file_stat_t *findFile(const QByteArray &key) const {
           auto it = find(key);