Re: Shouldn't g_quark_from_static_string be const?
- From: Owen Taylor <otaylor redhat com>
- To: Nicolás Lichtmaier <nick technisys com ar>
- Cc: gtk-devel-list gnome org
- Subject: Re: Shouldn't g_quark_from_static_string be const?
- Date: Fri, 20 Dec 2002 10:55:10 -0500 (EST)
Nicolás Lichtmaier <nick technisys com ar> writes:
> Hi!
>
> Shouldn't g_quark_from_static_string be declared with G_GNUC_CONST (
> __attribute__(__const__) ) ?
>
> As the static string won't ever change, it's safe for the compiler to
> assume that the function output is entirely dependant on the pointer
> value itself.
>
> This way GCC will be able to take the function call out of
> loops... What do you think?
A thing to think about here, is that G_GNUC_CONST also means
side-effect-free, while g_quark_from_static_string() does have
a side effect - it creates the quark.
So,
g_quark_from_static_string ("foo");
g_quark_try_string ("foo");
Will change in behavior since GCC will optimize out the first call;
this came up some when we added G_GNUC_CONST to the get_type()
functions.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]