hash iteration macros proposal
luben karavelov
luben at unixsol.org
Fri Aug 13 20:38:02 UTC 2010
On 13.08.2010 20:18, luben wrote:
> Attached is a patch that that adds an abstraction to commonly used
> functionality in the code base - to iterate raw hashes.
>
> It is implemented as a macros:
> 1st macro adds syntax like:
>
> parrot_hash_iterate(hash, <some_code_here>);
>
> in the code, there is defined _bucket variable;
>
> for example
>
> parrot_hash_iterate(hash, _bucket->value += 1);
>
> The code could be of arbitrary size;
>
> the second macro "parrot_hash_iterator" is modeled after
> hashiterator.pmc. For example usage, look there.
>
> I have replaced all manual iterations of hashes with this macros. This
> will give us a flexibility to change hash internals only changing 2
> files - hash.c and hash.h whithout breaking unknown places that poke
> with hash internals.
>
> As macros, they are text substitution, so there will be no performace hit.
>
> I am open to comments and suggestions
>
> luben
>
Here is updated patch that does not have code unrelated to the topic. I
have found some more places where we could use these macros and I am
converting them also.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: macros.diff
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20100813/898d97df/attachment-0001.diff>
More information about the parrot-dev
mailing list