mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
bitmap:improve memory usage using CHAR_BITS and unsigned CHAR
Using char instead of int allows for simpler definitions of the DOCIDSET macros so the code is easier to understand and consistent with respect to memory-usage. Estimated reduction of memory-usage for bitmap about 8 times.
This commit is contained in:
parent
a03769db17
commit
c033cb4c07
1 changed files with 5 additions and 5 deletions
10
lib/query.cc
10
lib/query.cc
|
@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages {
|
||||||
} notmuch_mset_messages_t;
|
} notmuch_mset_messages_t;
|
||||||
|
|
||||||
struct _notmuch_doc_id_set {
|
struct _notmuch_doc_id_set {
|
||||||
unsigned int *bitmap;
|
unsigned char *bitmap;
|
||||||
unsigned int bound;
|
unsigned int bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))
|
#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT)
|
||||||
#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))
|
#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT)
|
||||||
|
|
||||||
struct visible _notmuch_threads {
|
struct visible _notmuch_threads {
|
||||||
notmuch_query_t *query;
|
notmuch_query_t *query;
|
||||||
|
@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx,
|
||||||
GArray *arr)
|
GArray *arr)
|
||||||
{
|
{
|
||||||
unsigned int max = 0;
|
unsigned int max = 0;
|
||||||
unsigned int *bitmap;
|
unsigned char *bitmap;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < arr->len; i++)
|
for (unsigned int i = 0; i < arr->len; i++)
|
||||||
max = MAX(max, g_array_index (arr, unsigned int, i));
|
max = MAX(max, g_array_index (arr, unsigned int, i));
|
||||||
bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));
|
bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);
|
||||||
|
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue