On Thu, 2008-01-24 at 11:40 +0800, Binary Chen wrote: > > > In glib there is a primitive named quark, it relates a ID with a > > > string, but whats the advantage for this? Can we use a string instead, > > > just to save some bytes for duplicated strings? > > > > It has the same advantages as string interning in any other > > language... > > Can you give me an example for this?
static GQuark foo_quark = 0; static const gchar *foo_str = "a-very-long-string-to-compare-many-times"; foo_quark = g_quark_from_static_string (foo_str); quark = g_quark_try_string (some_str); if (quark == foo_quark) g_print ("'%s' matches '%s'\n", some_str, foo_str); this could also be done using g_intern_static_string() and g_intern_string(), and then comparing the pointers. ciao, Emmanuele. -- Emmanuele Bassi, W: http://www.emmanuelebassi.net B: http://log.emmanuelebassi.net _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list