Re: questioning glib r5316 by mclasen



On Mon, 2007-05-14 at 08:49 -0400, Matthias Clasen wrote:

> Of course, it doesn't make a huge difference, and thus the change is not
> worth fighting over. If you don't like it, just revert it Tim. The only
> way to really make a dent in the link-time overhead of gobject-based
> libraries would be to get rid of the badly designed enumeration abi that
> is forcing thousands of relocations upon us. But we are probably stuck
> with that...

The are a range of easy fixes.  We just need to do *something* instead
of waiting :).  Here is what currently glib-mkenums generates:

GType
pango_style_get_type (void)
{
  static GType etype = 0;
  if (etype == 0) {
    static const GEnumValue values[] = {
      { PANGO_STYLE_NORMAL, "PANGO_STYLE_NORMAL", "normal" },
      { PANGO_STYLE_OBLIQUE, "PANGO_STYLE_OBLIQUE", "oblique" },
      { PANGO_STYLE_ITALIC, "PANGO_STYLE_ITALIC", "italic" },
      { 0, NULL, NULL }
    };
    etype = g_enum_register_static (g_intern_static_string ("PangoStyle"), values);
  }
  return etype;
}

Possible fixes can be divided into two groups: 1) introducing new API,
2) changing glib-mkenum without changing glib API.  Main problem with
first approach is that it breaks people's code when they make tarballs
using newer glib and users try to compile using older glib.  We can of
course condition on the available glib version as a solution.  Main
problem with second approach is that it does not fix the problem
completely.

There is in fact a third option which is what I think we should do:
chang glib-mkenum to improve the situation immediately, and add new API
that we can assume and use, say, a couple years from now.

  - Immediate "fix" in glib-mkenum:  Remove both the static and const
qualifiers from the array definition.  This ensures that it will be
allocated on stack.  Then g_memdup the array and pass to
g_enum/flags_register_static.  

...

Ok, I see I'm just replicating discussion on bug 168003, so I'll shut
up :).

> Matthias

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759






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