On Sat, 2009-08-01 at 17:42 +0200, Łukasz Pankowski wrote:
> Another performance related usage of the weak variables (apart from one
> you mentioned in the bug comment #3) is that properties return weak
> variables so the values are copied unless assigned to the weak variable
> (as in the code below) and here "weak t = a.str" shortcut would also be
> convenient.
> 
> 
> class Foo {
>     public string str { get; set; }
> }
> 
> void main ()
> {
>     Foo a = new Foo();
> 
>     // uses g_strdup to duplicate the string
>     var s = a.str;
>     // no duplication needed
>     weak string t = a.str;
> }

Strings in vala are immutable value objects. If you are in need of a
mutable (cow) reference counted string implementation, that would
certainly be possible, although I doubt that the end result would
perform better than current situation. It's not like in C++ for example,
where you could optimize by inlining certain critical parts.

The discussion about property getters might interest you too:

http://mail.gnome.org/archives/vala-list/2008-December/msg00144.html


Regards,
Hans


_______________________________________________
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to