On Tue, Sep 8, 2009 at 6:52 PM, Gustavo Sverzut Barbieri<barbi...@profusion.mobi> wrote: > Hello all, but specially Cedric and Jorge as one of you did initial > eina_inlist and we're about to release eina as 1.0 so we need to know > if things need/could be changed to improve things before that. > > Today eina_inlist does not keep an accounting member as its eina_list > counterpart, instead it keeps a pointer to "last" that is just valid > on the head member (as we'll not walk the list updating all ->last as > we append stuff). That leaves us with a sizeof(pointer) lost in every > member but the first. > > Two options with that: > - add accounting: suggested by raster, it does make sense as it > would make eina_inlist_count() O(1) and behavior similar to eina_list, > better use of that pointer. > - ultra-dirty hack to remove extra pointer. The hack bases on the > fact that we just use ->last from the first node, that always have the > ->prev == NULL. So we could have the first ->prev == ->last, but how > to know it's the first then, you might ask? Easy! Just use the fact > that valid addresses are multiple of sizeof(word) and you're done, no > supported platform uses less than 4 bytes, so ->prev = ->last | 1; > would work, and checks for ->last & 1 would tell you if it's the case > or not. > > The ultra dirty hack could be used to save the extra ->accounting from > eina_list as well, and instead of adding last as said in the previous > example, we could store accounting there. Dirty but useful, if people > are using macros then we've almost no porting to do. As this uses > ->prev (a not so used pointer in outer world) we don't have much work > to do, just introduce EINA_LIST_FIRST_IS() and EINA_LIST_LAST_IS() > (the last would still check for NULL, but just to make further changes > easier).
We used this trick with callback pointers in EWL for quite a while. It worked fine, but we eventually needed more than 2 bits for the flags. During that time, I did receive quite a few complaints about it being a little difficult to figure out what the macros were doing, but people figured it out pretty quickly when they took the time to look at it. > What do you think? Should we change eina_inlist to have an accounting > and still use 3 pointers per node? Should we move to the said trick? > Also for eina_list? SAY IT SOON OR LIVE WITH THAT :-D ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel