[asterisk-dev] [Code Review] astobj2: Avoid using temporary objects + ao2_find() with OBJ_POINTER

schmidts reviewboard at asterisk.org
Wed Jun 8 09:40:44 CDT 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1184/#review3691
-----------------------------------------------------------

Ship it!


i really like this change. Cause it should be easy to get rid of some unnecessary non OBJ_POINTER callbacks, which would increase the searchspeed through a container.

i only have found some places about missing documentation for OBJ_KEY


/branches/1.8/include/asterisk/astobj2.h
<https://reviewboard.asterisk.org/r/1184/#comment7442>

    plz add OBJ_KEY description here



/branches/1.8/include/asterisk/astobj2.h
<https://reviewboard.asterisk.org/r/1184/#comment7441>

    plz add OBJ_KEY description here too



/branches/1.8/main/astobj2.c
<https://reviewboard.asterisk.org/r/1184/#comment7440>

    the optimization is to use OBJ_KEY so this XXX could be changed or even removed.


- schmidts


On 2011-05-27 17:52:05, Russell Bryant wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1184/
> -----------------------------------------------------------
> 
> (Updated 2011-05-27 17:52:05)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> There is a fairly common pattern making its way through the code base where we put a temporary object on the stack so we can call ao2_find() with OBJ_POINTER.  The purpose is so that it can be passed into the object hash function.  However, this really seems like a hack and potentially error prone.  This patch is a first stab at approach to avoid having to do that.
> 
> It adds a new flag, OBJ_KEY, which can be used instead of OBJ_POINTER in these situations.  Then, the hash function can know whether it was given an object or some custom data to hash.
> 
> The patch also changes some uses of ao2_find() for iax2_user and iax2_peer objects to reflect how OBJ_KEY would be used.
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/channels/chan_iax2.c 321272 
>   /branches/1.8/include/asterisk/astobj2.h 321272 
>   /branches/1.8/main/astobj2.c 321272 
>   /branches/1.8/tests/test_astobj2.c 321272 
> 
> Diff: https://reviewboard.asterisk.org/r/1184/diff
> 
> 
> Testing
> -------
> 
> It compiles.  I'm just throwing out the idea right now.  If people seem to think it makes sense, I will certainly try calls before committing anything.
> 
> 
> Thanks,
> 
> Russell
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110608/a9d262e6/attachment-0001.htm>


More information about the asterisk-dev mailing list