! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
G_TYPE_INVALID seems to be overkill for setting a type to 0
Status:
RESOLVED: INVALID

Comments

Description Nick Schermer editbugs 2007-06-04 20:55:55 CEST
I'm not really sure here, but you use G_TYPE_INVALID in all the class init functions (including exo) to 'initialize' the type, but isn't this a bit overkill? Because the  G_TYPE_INVALID defenition is G_TYPE_MAKE_FUNDAMENTAL (0) -> g_type_fundamental (0), so you call a function which does a table lookup just to get a zero? Seems a bit too much work for me, but I could be wrong here.

You could just use something like G_UNLIKELY (type == 0) instead. Not very impressing, but it works ;).
Comment 1 Nick Schermer editbugs 2007-06-04 21:01:21 CEST
Btw. the G_DEFINE_TYPE functions also use a 0:

static GType g_define_type_id = 0;
if (G_UNLIKELY (g_define_type_id == 0))
  {
    g_define_type_id = g_type_register_static_simple (...);
  }
Comment 2 Nick Schermer editbugs 2007-06-05 12:03:44 CEST
Changed G_TYPE_INVALID to 0, but there were not binary size changes, so I was wrong here (or GCC is smart enough to make it a zero directly, duno).

Changing the resolution to (G_TYPE_)INVALID ;).

Bug #3318

Reported by:
Nick Schermer
Reported on: 2007-06-04
Last modified on: 2009-07-17

People

Assignee:
Jannis Pohlmann
CC List:
0 users

Version

Attachments

Additional information