Re: [Vala] reference management.



On Tue, 2007-03-20 at 18:17 +0000, jamie wrote:


I would personally use GString (with ref counting patch to glib) as the
basic string type in vala as that this can be managed efficiently
without copying strings via default strong refs. Its also a lot faster
for string concatenation as it allocates extra memory for potential
string growth in chunks (using gslice I believe)

For C interfacing, a cString type should be used with the compiler
automatically converting  from GString to cString just like Delphi does
with its strings.

also the way delphi ref counts strings is to use copy-on-write so a
string is only ever copied when its written (and never when its
assigned) - this makes ref counted strings highly efficient and removes
the need for the "weak" optimization with strings.

(on copying the ref count of the string being copied is decremented)

In addition, isn't "weak" the same as const?

jamie.






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