On Fri, Jun 19, 2009 at 9:54 PM, Carsten Haitzler<[email protected]> wrote:
> On Fri, 19 Jun 2009 15:11:28 -0300 Gustavo Sverzut Barbieri
> <[email protected]> said:
>
>> On Fri, Jun 19, 2009 at 3:02 AM, Sergey
>> Semernin<[email protected]> wrote:
>> > Hello, All.
>> >
>> > Now, gadget managers can distinguish which gadgets are usable for
>> > shelfs, toolbars, desktop and etc. I was added to E_Gadcon_Client_Class
>> > new callback 'is_site', and when gadget manager build list of available
>> > gadgets it try to call this functor:
>> >    -- If 'is_site' undefined, then it means that this gadget can be used
>> > everywhere.
>> >    -- Otherwise, manager call 'is_site' with a name of the site and if
>> > result is EINA_FALSE, then this gadget should not be included in available
>> > gadgets list.
>> >    -- If manager can't determine target site of gadgets it call 'is_site
>> > (NULL)', so this case should be properly matched in gadget module.
>>
>> Ok, in order to avoid adding overhead document that is_site() will get
>> a stringshared string and you pre-stringshare the known names as you
>> listed below. Before calling is_site() you certify that the parameter
>> is stringshared already or do that once. Then functions can just check
>> for pointers being equal and avoid strcmp().
>
> to be realistic - this will never make a difference. you many gadgets do you
> expect to have in a list? 100? 1000? more? you know that if 1 module provides 
> 1
> gadget... you'll run out of fd's long before you have enough items for this to
> matter. this is micro-optimisation with no real effect. :( every list item
> created will probably do dozens and dozens of strcmp's. this won't make a dent
> at all. even if they were all removed you'd still barely notice. :)

But why do a not so good solution when the other solution is actually
simpler code-wise? You'd be changing handling of pointers (!NULL) and
then a comparison by just comparing two values.

Actually, after discussing this Sergey just wisely remembered that we
should use simple ENUM/integers and that gets even more simpler. Given
the number of things this could grow, I would even say that integers
should be powers of 2 and use a mask of accepted types, then no need
to do functions and all, just set your mask and be happy.


>> Last but not least, since we have common stuff here, provide the
>> following functions by default:
>>  - PREFIX_only_shelf_is_site()
>>  - PREFIX_only_desktop_is_site()
>>  - PREFIX_only_efm_toolbar_is_site()
>>  - PREFIX_not_efm_toolbar_is_site()
>>
>> they should be used by modules to avoid duplication, and you can have
>> them to use the globals with the stringshared version of names you
>> created before (at init time).
>
> what are these funcs. it's not clearly explained.

they would be common functions most modules would set instead of
creating their own replicas, like defining this in every module:

BLA_is_site(const char *query)
{
    return (!query || strcmp(query, "desktop") == 0);
}

one would set: is_site = PREFIX_only_desktop_is_site. (PREFIX = some
prefix we choose for this, like e_gadcon_client).

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to