Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C0359431FBF for ; Mon, 11 Feb 2013 10:24:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bU6ZgLe7Gnhw for ; Mon, 11 Feb 2013 10:24:34 -0800 (PST) Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id C2A6D431FBC for ; Mon, 11 Feb 2013 10:24:28 -0800 (PST) Received: (qmail 21948 invoked from network); 10 Feb 2013 18:24:27 +0100 Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo) (87.210.109.73) by srv047132.webreus.nl with SMTP; 10 Feb 2013 18:24:27 +0100 From: Robert Mast To: notmuch@notmuchmail.org Subject: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR Date: Sun, 10 Feb 2013 18:24:16 +0100 Message-Id: <1360517056-7066-1-git-send-email-beheerder@tekenbeetziekten.nl> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl> References: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl> Cc: Robert Mast X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Feb 2013 18:24:36 -0000 A little bug-fix to learn how to contribute to nutmuch, this time a combined commit with git rebase to provide one patch from 15.1. --- lib/query.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/query.cc b/lib/query.cc index e9c1a2d..7381a54 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages { } notmuch_mset_messages_t; struct _notmuch_doc_id_set { - unsigned int *bitmap; + unsigned char *bitmap; unsigned int bound; }; -#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int)) -#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int)) +#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT) +#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT) struct visible _notmuch_threads { notmuch_query_t *query; @@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx, GArray *arr) { unsigned int max = 0; - unsigned int *bitmap; + unsigned char *bitmap; for (unsigned int i = 0; i < arr->len; 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) return FALSE; -- 1.7.9.5