[PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR
authorRobert Mast <beheerder@tekenbeetziekten.nl>
Wed, 13 Feb 2013 15:11:43 +0000 (16:11 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:36 +0000 (09:53 -0800)
0d/90a9a42aa49e407bb33b3619b31e1dc444c133 [new file with mode: 0644]

diff --git a/0d/90a9a42aa49e407bb33b3619b31e1dc444c133 b/0d/90a9a42aa49e407bb33b3619b31e1dc444c133
new file mode 100644 (file)
index 0000000..865c7c1
--- /dev/null
@@ -0,0 +1,85 @@
+Return-Path: <beheerder@tekenbeetziekten.nl>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 68FB7431FC9\r
+       for <notmuch@notmuchmail.org>; Wed, 13 Feb 2013 07:12:09 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 0QYAOv8j0pAD for <notmuch@notmuchmail.org>;\r
+       Wed, 13 Feb 2013 07:12:06 -0800 (PST)\r
+Received: from srv047132.webreus.nl (srv047132.webreus.nl [46.235.47.132])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id EB707431FC7\r
+       for <notmuch@notmuchmail.org>; Wed, 13 Feb 2013 07:12:05 -0800 (PST)\r
+Received: (qmail 16021 invoked from network); 13 Feb 2013 16:12:04 +0100\r
+Received: from ip73-109-210-87.adsl2.static.versatel.nl (HELO linux2.foo)\r
+       (87.210.109.73)\r
+       by srv047132.webreus.nl with SMTP; 13 Feb 2013 16:12:04 +0100\r
+From: Robert Mast <beheerder@tekenbeetziekten.nl>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR\r
+Date: Wed, 13 Feb 2013 16:11:43 +0100\r
+Message-Id: <1360768303-4228-1-git-send-email-beheerder@tekenbeetziekten.nl>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>\r
+References: <1359917491-17178-1-git-send-email-beheerder@tekenbeetziekten.nl>\r
+Cc: Robert Mast <beheerder@tekenbeetziekten.nl>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 13 Feb 2013 15:12:09 -0000\r
+\r
+diff --git a/lib/query.cc b/lib/query.cc\r
+index e9c1a2d..7381a54 100644\r
+--- a/lib/query.cc\r
++++ b/lib/query.cc\r
+@@ -39,12 +39,12 @@ typedef struct _notmuch_mset_messages {\r
+ } notmuch_mset_messages_t;\r
\r
+ struct _notmuch_doc_id_set {\r
+-    unsigned int *bitmap;\r
++    unsigned char *bitmap;\r
+     unsigned int bound;\r
+ };\r
\r
+-#define DOCIDSET_WORD(bit) ((bit) / sizeof (unsigned int))\r
+-#define DOCIDSET_BIT(bit) ((bit) % sizeof (unsigned int))\r
++#define DOCIDSET_WORD(bit) ((bit) / CHAR_BIT)\r
++#define DOCIDSET_BIT(bit) ((bit) % CHAR_BIT)\r
\r
+ struct visible _notmuch_threads {\r
+     notmuch_query_t *query;\r
+@@ -359,11 +359,11 @@ _notmuch_doc_id_set_init (void *ctx,\r
+                         GArray *arr)\r
+ {\r
+     unsigned int max = 0;\r
+-    unsigned int *bitmap;\r
++    unsigned char *bitmap;\r
\r
+     for (unsigned int i = 0; i < arr->len; i++)\r
+       max = MAX(max, g_array_index (arr, unsigned int, i));\r
+-    bitmap = talloc_zero_array (ctx, unsigned int, 1 + max / sizeof (*bitmap));\r
++    bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);\r
\r
+     if (bitmap == NULL)\r
+       return FALSE;\r
+-- \r
+1.7.9.5\r
+\r