aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-10-20 19:31:46 +0800
committerMilan Crha <mcrha@redhat.com>2010-10-20 19:34:53 +0800
commit7a07c80767950787601924b2b8091c8a0cb3371a (patch)
treeeaf24f2ab4aca5795ebac2353e7dbde991d962c9 /e-util
parentb1f84e3c36a3e64caa8eac4b7f88252225cbf405 (diff)
downloadgsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar.gz
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar.bz2
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar.lz
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar.xz
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.tar.zst
gsoc2013-evolution-7a07c80767950787601924b2b8091c8a0cb3371a.zip
Bug #630504 - Precache collate keys before sorting in EReflowModel
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-sorter-array.c21
-rw-r--r--e-util/e-sorter-array.h9
2 files changed, 25 insertions, 5 deletions
diff --git a/e-util/e-sorter-array.c b/e-util/e-sorter-array.c
index e19084c4d6..3e559acb3a 100644
--- a/e-util/e-sorter-array.c
+++ b/e-util/e-sorter-array.c
@@ -58,7 +58,7 @@ esort_callback (gconstpointer data1, gconstpointer data2, gpointer user_data)
int1 = *(gint *)data1;
int2 = *(gint *)data2;
- ret_val = esa->compare (int1, int2, esa->closure);
+ ret_val = esa->compare (int1, int2, esa->cmp_cache, esa->closure);
if (ret_val != 0)
return ret_val;
@@ -84,10 +84,19 @@ esa_sort (ESorterArray *esa)
for (i = 0; i < rows; i++)
esa->sorted[i] = i;
- if (esa->compare)
+ if (esa->compare) {
+ if (esa->create_cmp_cache)
+ esa->cmp_cache = esa->create_cmp_cache (esa->closure);
+
g_qsort_with_data (
esa->sorted, rows, sizeof (gint),
esort_callback, esa);
+
+ if (esa->cmp_cache) {
+ g_hash_table_destroy (esa->cmp_cache);
+ esa->cmp_cache = NULL;
+ }
+ }
}
static void
@@ -225,20 +234,22 @@ e_sorter_array_append (ESorterArray *esa, gint count)
ESorterArray *
e_sorter_array_construct (ESorterArray *esa,
+ ECreateCmpCacheFunc create_cmp_cache,
ECompareRowsFunc compare,
gpointer closure)
{
+ esa->create_cmp_cache = create_cmp_cache;
esa->compare = compare;
esa->closure = closure;
return esa;
}
ESorterArray *
-e_sorter_array_new (ECompareRowsFunc compare, gpointer closure)
+e_sorter_array_new (ECreateCmpCacheFunc create_cmp_cache, ECompareRowsFunc compare, gpointer closure)
{
ESorterArray *esa = g_object_new (E_SORTER_ARRAY_TYPE, NULL);
- return e_sorter_array_construct (esa, compare, closure);
+ return e_sorter_array_construct (esa, create_cmp_cache, compare, closure);
}
static void
@@ -257,6 +268,8 @@ static void
e_sorter_array_init (ESorterArray *esa)
{
esa->rows = 0;
+ esa->cmp_cache = NULL;
+ esa->create_cmp_cache = NULL;
esa->compare = NULL;
esa->closure = NULL;
esa->sorted = NULL;
diff --git a/e-util/e-sorter-array.h b/e-util/e-sorter-array.h
index 9a1d3fcfef..94ca51872f 100644
--- a/e-util/e-sorter-array.h
+++ b/e-util/e-sorter-array.h
@@ -39,12 +39,17 @@ G_BEGIN_DECLS
#define _E_COMPARE_ROWS_FUNC_H_
typedef gint (*ECompareRowsFunc) (gint row1,
gint row2,
+ GHashTable *cmp_cache,
gpointer closure);
#endif
+typedef GHashTable * (*ECreateCmpCacheFunc) (gpointer closure);
+
typedef struct {
ESorter base;
+ GHashTable *cmp_cache;
+ ECreateCmpCacheFunc create_cmp_cache;
ECompareRowsFunc compare;
gpointer closure;
@@ -61,9 +66,11 @@ typedef struct {
GType e_sorter_array_get_type (void);
ESorterArray *e_sorter_array_construct (ESorterArray *sorter,
+ ECreateCmpCacheFunc create_cmp_cache,
ECompareRowsFunc compare,
gpointer closure);
-ESorterArray *e_sorter_array_new (ECompareRowsFunc compare,
+ESorterArray *e_sorter_array_new (ECreateCmpCacheFunc create_cmp_cache,
+ ECompareRowsFunc compare,
gpointer closure);
void e_sorter_array_clean (ESorterArray *esa);
void e_sorter_array_set_count (ESorterArray *esa,