[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIZEOF macro

From: Jim Meyering
Subject: Re: SIZEOF macro
Date: Fri, 25 Dec 2009 11:44:19 +0100

Eric Blake wrote:

> According to Eric Blake on 12/24/2009 4:21 PM:
>> According to Bruno Haible on 12/24/2009 1:08 PM:
>>>>> Either way we create macros.h and put ASSERT there
>>> Done this this big commit, now.
>> Hmm.  macros.h defines SIZEOF, and test-argv-iter.c defines
>> ARRAY_CARDINALITY, both of which are used to determine the size of an
>> array.  I kind of prefer the name in test-argv-iter (to me, sizeof implies
>> a size_t count of bytes, not the number of elements).  Is it okay to
>> rename the macro in macros.h to ARRAY_CARDINALITY, adjust all callers, and
>> to simplify test-argv-iter?
> Like this?  It's also pretty quick to go with a shorter name of CARDINALITY:

Good compromise.

> for f in `git grep -l ARRAY_CARDINALITY tests`; do \
> done

Not that the above is terribly slow, but on certain systems
where forking is expensive, you might appreciate avoiding
nearly all of those fork/exec pairs:

    git grep -l ARRAY_CARDINALITY tests \
      | xargs perl -pi -e 's/ARRAY_CARDINALITY/CARDINALITY/'

> 2009-12-24  Eric Blake  <address@hidden>
>       tests: rename SIZEOF to ARRAY_CARDINALITY
>       * tests/macros.h (SIZEOF): Rename...
>       (ARRAY_CARDINALITY): ...to this.
>       * tests/test-argv-iter.c (ARRAY_CARDINALITY): Delete.
>       * tests/test-hash.c (ARRAY_CARDINALITY): Likewise.
>       * tests/test-array_list.c: Prefer ARRAY_CARDINALITY over SIZEOF.
>       * tests/test-array_oset.c: Likewise.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]