On Mon, 4 Apr 2005 22:07:43 +0900 David Stevenson <david.35472@...> babbled:
> Saw some changes in evas_object_list.c yesterday and spotted some
> minor stuff that could be tidied up... (see attached file
yeah - a fair enough patch :) in.
> Also, I was wondering if the idea behind the "for (l = list; l; l =
> l->next)" is to avoid deferencing pointers in the condition each time
no - its just another way to walk a list from start to end in a nice simple for construct :) set l to the first list member, as long as l is not NULL (empty list or end of list) go to the next list node.
> through the loop? This seems OK in evas_object_list_find, but as for
> evas_object_list_append, we have:
> if (list->last) l = list->last;
if the last member is not null, use it. (evas lists are optimised by tracking count and last member at all times for fast list counts and appends).
> else for (l = list; l; l = l->next);
if no last member is set (NULL) something is weird so fallback to just walking to the end of the list...
> l->next = new_l;
l is the last list node = just set its next member to be the one we are appending :)
> If the if condition here is false and the else condition executes,
> then aren't we are screwed on "l->next = ..." since "l" will be NULL
> on completion of the for loop?
good point - should make the middle check "l && l->next" not "l" :) but its a fallback if the last memebr is null- which it never is :)
> Also, in evas_object_list_remove I see that there is no check to
> confirm that the in_item is actually present in the in_list before
> removing it (if it was part of another list, it would get removed from
> that one instead)... is this up to the caller to make sure the item is
> actually a part of the list before attempting to remove it?
yeah - it's up to the caller to do the right thing. as this is only used internally in evas - evas kind of trusts itself. its a chunk of overhead to do these tests and the idea is to keep the overhead low :)
> I haven't attempted patches for the last two things cos I'm not sure I
> fully understand the usage...
> David@... (e-taro)
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) raster@...
Tokyo, Japan (東京 日本)