unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: "Robert Mast" <beheerder@tekenbeetziekten.nl>
To: <notmuch@notmuchmail.org>
Subject: RE: [english 100%] [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR
Date: Wed, 13 Feb 2013 16:15:32 +0100	[thread overview]
Message-ID: <007501ce09fc$f85e20d0$e91a6270$@nl> (raw)
In-Reply-To: <1360768303-4228-1-git-send-email-beheerder@tekenbeetziekten.nl>

Somehow my comments don't get through... I'll try it another way.

-----Oorspronkelijk bericht-----
Van: Robert Mast [mailto:beheerder@tekenbeetziekten.nl] 
Verzonden: woensdag 13 februari 2013 16:12
Aan: notmuch@notmuchmail.org
CC: Robert Mast
Onderwerp: [english 100%] [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR

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


.

  reply	other threads:[~2013-02-13 15:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03 18:51 [PATCH] This patch is a little finger excercise for working with git. I found a piece of code that I didn't understand at first Robert Mast
2013-02-03 20:01 ` Austin Clements
2013-02-10 13:13 ` [PATCH] convert bitmap to unsigned char Robert Mast
2013-02-11 18:56   ` Carl Worth
2013-02-10 17:24 ` [PATCH] bitmap:improve memory usage using CHAR_BITS and unsigned CHAR Robert Mast
2013-02-13 15:11 ` Robert Mast
2013-02-13 15:15   ` Robert Mast [this message]
2013-02-13 15:32 ` Robert Mast
2013-02-13 16:21   ` Carl Worth
2013-02-16 11:37   ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='007501ce09fc$f85e20d0$e91a6270$@nl' \
    --to=beheerder@tekenbeetziekten.nl \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).