Re: g_type_instance_is_a (was Cairo 1.3 performance loss)



On Thu, 2007-01-25 at 15:55 +0100, Nick Schermer wrote:
> 
> On Thu, 25 Jan 2007 09:33:37 -0500, Matthias Clasen <mclasen redhat com> wrote:
> >> 	similarly, this only calls:
> >> 
> >> 	g_return_if_fail (GTK_IS_WIDGET (widget));
> >> 
> >> 	perhaps it just happens millions of times; odd.
> >> 
> 
> I know the g_return check are useful (and needed) for developers, but they are not important for users when the application is stable. So maybe it's an idea to add a macro for disabling the check when you compile gtk without debug?
> 
> #ifndef NDEBUG
> #define _gtk_assert(expr)                  g_assert (expr)
> #define _gtk_assert_not_reached()          g_assert_not_reached ()
> #define _gtk_return_if_fail(expr)          g_return_if_fail (expr)
> #define _gtk_return_val_if_fail(expr, val) g_return_val_if_fail (expr, (val))
> #else
> #define _gtk_assert(expr)                  G_STMT_START{ (void)0; }G_STMT_END
> #define _gtk_assert_not_reached()          G_STMT_START{ (void)0; }G_STMT_END
> #define _gtk_return_if_fail(expr)          G_STMT_START{ (void)0; }G_STMT_END
> #define _gtk_return_val_if_fail(expr, val) G_STMT_START{ (void)0; }G_STMT_END
> #endif
> 
> Maybe it's just an crazy idea, but if you want to get rid of all the checks, this might be the solution...
> 

If you want that, just configure with --enable-debug=no. Note that this
is not recommended, even for stable builds:

--enable-debug.  Turns on various amounts of debugging support. Setting
this to 'no' disables g_assert(), g_return_if_fail(),
g_return_val_if_fail() and all cast checks between different object
types. Setting it to 'minimum' disables only cast checks. Setting it to
'yes' enables runtime debugging. The default is 'minimum'. Note that
'no' is fast, but dangerous as it tends to destabilize even mostly
bug-free software by changing the effect of many bugs from simple
warnings into fatal crashes. Thus --enable-debug=no should not be used
for stable releases of GLib.




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