Re: g_intern_static_string() for type names as small optimization
- From: Emmanuele Bassi <ebassi gmail com>
- To: gtk-devel-list gnome org
- Subject: Re: g_intern_static_string() for type names as small optimization
- Date: Wed, 16 Jan 2008 15:08:27 +0000
On Wed, 2008-01-16 at 16:53 +0200, Andrew W. Nosenko wrote:
> Cite from http://mail.gnome.org/archives/gtk-devel-list/2007-April/msg00216.html
>
> "Matthias Clasen" <matthias clasen gmail com> wrote:
> : On 4/27/07, Damon Chaplin <damon karuna eclipse co uk> wrote:
> : : Why do the *_type_register_static() functions use
> : : g_intern_static_string() for the type name?
> :
> : It is just a small optimization. Apps are free to use it, but it is not
> : the end of the world if they don't.
>
> Matthias (or anyone else), could you explain, what this "small
> optimization" optimizes (what use-cases, on what way, etc), why and
> how big win/profit gives?
just read the description of g_intern_static_string() and
g_intern_string():
Returns a canonical representation for string. Interned strings can be
compared for equality by comparing the pointers, instead of using
strcmp(). g_intern_static_string() does not copy the string, therefore
string must not be freed or modified.
for a interned strings pool, there's also a wikipedia page:
http://en.wikipedia.org/wiki/String_intern_pool
ciao,
Emmanuele.
--
Emmanuele Bassi,
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]