From c9715f0a81f0dcb36d5266346facafd3f52511ec Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 30 Jun 2004 19:55:29 +0000 Subject: Set the size of the ptrarray to prevent potentially realloc'ing several 2004-06-30 Jeffrey Stedfast * providers/imap4/camel-imap4-search.c (imap4_body_contains): Set the size of the ptrarray to prevent potentially realloc'ing several times. svn path=/trunk/; revision=26555 --- camel/providers/imap4/camel-imap4-search.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'camel/providers/imap4/camel-imap4-search.c') diff --git a/camel/providers/imap4/camel-imap4-search.c b/camel/providers/imap4/camel-imap4-search.c index 4a23dee83e..0a10ea5139 100644 --- a/camel/providers/imap4/camel-imap4-search.c +++ b/camel/providers/imap4/camel-imap4-search.c @@ -174,9 +174,11 @@ imap4_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam } else { r = e_sexp_result_new (f, ESEXP_RES_ARRAY_PTR); r->value.ptrarray = g_ptr_array_new (); + g_ptr_array_set_size (r->value.ptrarray, summary_set->len); + r->value.ptrarray->len = summary_set->len; for (i = 0; i < summary_set->len; i++) { info = g_ptr_array_index (summary_set, i); - g_ptr_array_add (r->value.ptrarray, (char *) camel_message_info_uid (info)); + r->value.ptrarray->pdata[i] = (char *) camel_message_info_uid (info); } } @@ -211,9 +213,11 @@ imap4_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam } else { r = e_sexp_result_new (f, ESEXP_RES_ARRAY_PTR); r->value.ptrarray = g_ptr_array_new (); + g_ptr_array_set_size (r->value.ptrarray, summary_set->len); + r->value.ptrarray->len = summary_set->len; for (i = 0; i < summary_set->len; i++) { info = g_ptr_array_index (summary_set, i); - g_ptr_array_add (r->value.ptrarray, (char *) camel_message_info_uid (info)); + r->value.ptrarray->pdata[i] = (char *) camel_message_info_uid (info); } } @@ -227,10 +231,10 @@ imap4_body_contains (struct _ESExp *f, int argc, struct _ESExpResult **argv, Cam if (search->current) { g_ptr_array_add (infos, search->current); } else { - for (i = 0; i < summary_set->len; i++) { - info = g_ptr_array_index (summary_set, i); - g_ptr_array_add (infos, info); - } + g_ptr_array_set_size (infos, summary_set->len); + infos->len = summary_set->len; + for (i = 0; i < summary_set->len; i++) + infos->pdata[i] = summary_set->pdata[i]; } retry: -- cgit v1.2.3