Re: what's diff -u GString GByteArray for gtk2?



Kang Jeong-Hee wrote:

> both struct aer similar.
> GString:
> struct _GString
> {
>   gchar  *str;
>   gsize len;
>   gsize allocated_len;
> };
> and
> GByteArray:
> struct _GByteArray
> {
>   guint8 *data;
>   guint   len;
> };
> 
> someone distinguise them?
As far as I can see, GString is more dynamic. For example you could have
an empty string in a 1KB buffer, then fill it one char at a time without
having to re-allocate mem => O(1). With a bytearray you'd have to
reallocate the buffer (maybe copying the old one) every time => O(n*n)
But if you only have a fixed size, you won't need the gstring power.

BYtE,
 Diego.



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