git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kuleshov <kuleshovmail@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: [RFC PATCH] hashmap API: introduce for_each_hashmap_entry() helper macro
Date: Thu, 17 Mar 2016 00:39:55 +0600	[thread overview]
Message-ID: <CANCZXo4uePVvk8_h2KuZQe4UFcFS1C76JvOfugK2nH3oH7TOsw@mail.gmail.com> (raw)
In-Reply-To: <xmqq37rq5m79.fsf@gitster.mtv.corp.google.com>

Hello Junio,

On Thu, Mar 17, 2016 at 12:09 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Alexander Kuleshov <kuleshovmail@gmail.com> writes:
>
>> diff --git a/hashmap.h b/hashmap.h
>> index ab7958a..b8b158c 100644
>> --- a/hashmap.h
>> +++ b/hashmap.h
>> @@ -95,4 +95,11 @@ static inline const char *strintern(const char *string)
>>       return memintern(string, strlen(string));
>>  }
>>
>> +#define for_each_hashmap_entry(map, type)            \
>> +     struct type *entry;                             \
>> +     struct hashmap_iter iter;                       \
>> +                                                     \
>> +     hashmap_iter_init(map, &iter);                  \
>> +     while ((entry = hashmap_iter_next(&iter)))
>> +
>
> This is an easy way to introduce decl-after-statement, i.e. needs an
> extra pair of {} around the thing.  It also forbids the callers from
> defining "entry" and "iter" as their own identifier outside the
> scope of this macro and use them inside the block that is iterated
> over by shadowing these two variables.
>
> Other than that, it looks like a good concept.  The syntax however
> needs more thought because of the above two issues, I think.

Thanks for feedback. Will fix first issue and think about second.

  reply	other threads:[~2016-03-16 18:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-16 16:39 [RFC PATCH] hashmap API: introduce for_each_hashmap_entry() helper macro Alexander Kuleshov
2016-03-16 18:09 ` Junio C Hamano
2016-03-16 18:39   ` Alexander Kuleshov [this message]
2016-03-16 23:47 ` Karsten Blees

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

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

  git send-email \
    --in-reply-to=CANCZXo4uePVvk8_h2KuZQe4UFcFS1C76JvOfugK2nH3oH7TOsw@mail.gmail.com \
    --to=kuleshovmail@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
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 NNTP newsgroup(s).