From defb3e67dce7bf684801594c70c7cf148a7eb0ed Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 31 Aug 2011 18:11:09 +0000 Subject: [PATCH] Wrapped tight loops inside a transaction to dramatically speedup things Monotone-Parent: 4d37ced4d18a580dd453377f39144a265c8580cf Monotone-Revision: 34186beb96b4e03796e53fcc658539fd1c3dbb8a Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2011-08-31T18:11:09 Monotone-Branch: ca.inverse.sogo --- OpenChange/MAPIStoreGCSFolder.m | 6 +++++- OpenChange/MAPIStoreMailFolder.m | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/OpenChange/MAPIStoreGCSFolder.m b/OpenChange/MAPIStoreGCSFolder.m index 370651c31..513b50106 100644 --- a/OpenChange/MAPIStoreGCSFolder.m +++ b/OpenChange/MAPIStoreGCSFolder.m @@ -226,6 +226,8 @@ max = [fetchResults count]; if (max > 0) { + ldb_transaction_start([[self context] connectionInfo]->oc_ctx); + for (count = 0; count < max; count++) { result = [fetchResults objectAtIndex: count]; @@ -260,7 +262,9 @@ lastModificationDate = cLastModified; } } - + + ldb_transaction_commit([[self context] connectionInfo]->oc_ctx); + if (foundChange) { ti = [NSNumber numberWithDouble: [now timeIntervalSince1970]]; diff --git a/OpenChange/MAPIStoreMailFolder.m b/OpenChange/MAPIStoreMailFolder.m index 1e143568f..2c1662e83 100644 --- a/OpenChange/MAPIStoreMailFolder.m +++ b/OpenChange/MAPIStoreMailFolder.m @@ -496,6 +496,9 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) fetchResults = [fetchResults sortedArrayUsingFunction: _compareFetchResultsByMODSEQ context: NULL]; + + ldb_transaction_start([[self context] connectionInfo]->oc_ctx); + for (count = 0; count < max; count++) { result = [fetchResults objectAtIndex: count]; @@ -519,6 +522,8 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) lastModseq = modseq; } + ldb_transaction_commit([[self context] connectionInfo]->oc_ctx); + ti = [NSNumber numberWithDouble: [now timeIntervalSince1970]]; [currentProperties setObject: ti forKey: @"SyncLastSynchronisationDate"];