Re: whats the purpose of quark



On Jan 23, 2008 9:54 PM, Bin Chen <binary chen gmail com> wrote:
Hi,

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...it gives you canonical strings that can be compared in
constant time with == instead of strcmp(), and it avoids repeated
copying of strings by storing away a single copy of the string that
can be used repeatedly later on.



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