]> git.pld-linux.org Git - packages/akonadi.git/blob - 0025-Avoid-repeated-calls-to-PimItem-flags-and-PimItem-ta.patch
boost rebuild
[packages/akonadi.git] / 0025-Avoid-repeated-calls-to-PimItem-flags-and-PimItem-ta.patch
1 From 55dc6d141a20e2438308214ab60c18e282dd7b43 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= <dvratil@redhat.com>
3 Date: Mon, 8 Dec 2014 10:33:51 +0100
4 Subject: [PATCH 25/30] Avoid repeated calls to PimItem::flags() and
5  PimItem::tags()
6
7 The queries results are not cached, so each call to those methods runs an SQL
8 query. At least in case of flags, this reduced the number of queries to one
9 query per changed item.
10 ---
11  server/src/storage/datastore.cpp | 10 ++++++----
12  1 file changed, 6 insertions(+), 4 deletions(-)
13
14 diff --git a/server/src/storage/datastore.cpp b/server/src/storage/datastore.cpp
15 index c9fa0c3..035395e 100644
16 --- a/server/src/storage/datastore.cpp
17 +++ b/server/src/storage/datastore.cpp
18 @@ -220,7 +220,8 @@ bool DataStore::setItemsFlags( const PimItem::List &items, const QVector<Flag> &
19    setBoolPtr( flagsChanged, false );
20  
21    Q_FOREACH ( const PimItem &item, items ) {
22 -    Q_FOREACH ( const Flag &flag, item.flags() ) {
23 +    const Flag::List itemFlags = item.flags();
24 +    Q_FOREACH ( const Flag &flag, itemFlags ) {
25        if ( !flags.contains( flag ) ) {
26          removedFlags << flag.name().toLatin1();
27          Query::Condition cond;
28 @@ -231,7 +232,7 @@ bool DataStore::setItemsFlags( const PimItem::List &items, const QVector<Flag> &
29      }
30  
31      Q_FOREACH ( const Flag &flag, flags ) {
32 -      if ( !item.flags().contains( flag ) ) {
33 +      if ( !itemFlags.contains( flag ) ) {
34          addedFlags << flag.name().toLatin1();
35          insIds << item.id();
36          insFlags << flag.id();
37 @@ -414,7 +415,8 @@ bool DataStore::setItemsTags( const PimItem::List &items, const Tag::List &tags,
38    setBoolPtr( tagsChanged, false );
39  
40    Q_FOREACH ( const PimItem &item, items ) {
41 -    Q_FOREACH ( const Tag &tag, item.tags() ) {
42 +    const Tag::List itemTags = item.tags();
43 +    Q_FOREACH ( const Tag &tag, itemTags ) {
44        if ( !tags.contains( tag ) ) {
45          // Remove tags from items that had it set
46          removedTags << tag.id();
47 @@ -426,7 +428,7 @@ bool DataStore::setItemsTags( const PimItem::List &items, const Tag::List &tags,
48      }
49  
50      Q_FOREACH ( const Tag &tag, tags ) {
51 -      if ( !item.tags().contains( tag ) ) {
52 +      if ( !itemTags.contains( tag ) ) {
53          // Add tags to items that did not have the tag
54          addedTags << tag.id();
55          insIds << item.id();
56 -- 
57 2.1.0
58
This page took 0.068689 seconds and 3 git commands to generate.