Re: [Vala] reference management.

On Die, 2007-03-20 at 18:42 +0000, jamie wrote:
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.

As our standard strings are considered constant, we'll do the same when
we have reference counted strings.

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

No, not quite. Consider for example const fields, they can only be
assigned once at initialization time, that limitation is not true for
weak fields.


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