diff options
author | Not Zed <NotZed@Ximian.com> | 2003-06-18 14:14:09 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2003-06-18 14:14:09 +0800 |
commit | 974980ed5eac4e0239220a60161bbe1a6b27e004 (patch) | |
tree | 153c9387db954ee482906b5af4c1531125f7a447 /camel/camel-folder-summary.c | |
parent | 9e1798ef897ccb60a5a57648b40ba43146d244a4 (diff) | |
download | gsoc2013-evolution-974980ed5eac4e0239220a60161bbe1a6b27e004.tar.gz gsoc2013-evolution-974980ed5eac4e0239220a60161bbe1a6b27e004.tar.zst gsoc2013-evolution-974980ed5eac4e0239220a60161bbe1a6b27e004.zip |
Calculate ranges to remove folder info's more efficiently. affects
2003-06-17 Not Zed <NotZed@Ximian.com>
* camel-vee-folder.c (vee_folder_remove_folder): Calculate ranges
to remove folder info's more efficiently. affects shutdown
performance on big vfolders signifinantly.
(vee_folder_build_folder): do the same here, when rebuilding a
folder's definition.
* camel-folder-summary.c (camel_folder_summary_remove_index): new
function to drop a range of index entries in one hit.
svn path=/trunk/; revision=21462
Diffstat (limited to 'camel/camel-folder-summary.c')
-rw-r--r-- | camel/camel-folder-summary.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 0a05d172ef..d584750055 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -1186,6 +1186,48 @@ void camel_folder_summary_remove_index(CamelFolderSummary *s, int index) } } +/** + * camel_folder_summary_remove_range: + * @s: + * @start: initial index + * @end: last index to remove + * + * Removes an indexed range of info records. + **/ +void camel_folder_summary_remove_range(CamelFolderSummary *s, int start, int end) +{ + if (end <= start+1) + return; + + CAMEL_SUMMARY_LOCK(s, summary_lock); + if (start < s->messages->len) { + CamelMessageInfo **infos; + int i; + + end = MIN(end+1, s->messages->len); + infos = g_malloc((end-start)*sizeof(infos[0])); + + for (i=start;i<end;i++) { + CamelMessageInfo *info = s->messages->pdata[i]; + + infos[i-start] = info; + g_hash_table_remove(s->messages_uid, camel_message_info_uid(info)); + } + + memmove(s->messages->pdata+start, s->messages->pdata+end, (s->messages->len-end)*sizeof(s->messages->pdata[0])); + g_ptr_array_set_size(s->messages, s->messages->len - (end - start)); + s->flags |= CAMEL_SUMMARY_DIRTY; + + CAMEL_SUMMARY_UNLOCK(s, summary_lock); + + for (i=start;i<end;i++) + camel_folder_summary_info_free(s, infos[i-start]); + g_free(infos); + } else { + CAMEL_SUMMARY_UNLOCK(s, summary_lock); + } +} + /* should be sorted, for binary search */ /* This is a tokenisation mechanism for strings written to the summary - to save space. |