[Glade-users] libglade: coding style: just curious about glade_xml_get_widget implementation

On Fri, 22 Oct 2004 19:49:45 -0700, David Hoover <karma deadmoose com> wrote:
does anyone know whether glade_xml_get_widget uses a hash
table on the input strings to look up the pointer to retrieve?
Either way, if it uses a hash table, how does it hash on the strings,
given that they are of variable length strings?

Its generaly good practice to not use glade_xml_get_widget more than once
per widget. 
    Usualy you dont need to beat around the bush too too much; i.e. you 
glade_xml_get_widget all widgets needed in one loading function, and then
you recieve the widget pointers in your signal callbacks (as a first arg or in 
the user_data, when you need more than one, you generally pass a struct 
poiner as the user_data).

A few good reasons for this is:
    - This allows abstraction from libglade and your code code
    - Generaly, you want to free the GladeXML object after use because
       it takes a significant amount of resources (so why keep it
lying around ?).
    - Its faster to pass the pointers directly  through callbacks than to do
      a hash lookup to find them (even if a hash lookup is relatively fast).
    - It allows you to write more generic code, i.e. your callbacks
can be reused
      throughout your interface for similar situations, if they dont
reference the
      widgets by name.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]