Re: [Vala] private fields vs bodyless properties



On Sat, 2008-05-31 at 02:36 +0200, Hans Vercammen wrote:
The reason for this is that the objects are gobjects and these are
created by a g_object_new call [1]. That function can only set
properties. So you need to have a property if you want to pass data to
your constructor

Thanks, yes you are absolutely right, I was not thinking outside the
vala box.

I have noticed that non-construct properties don't go through the
g_object_new argument list. Which caused some confusion; is this some
sort of optimization?

Yes, setting properties via g_object_new (and thus GValue) is quite a
bit slower than directly using the property setters. It probably doesn't
matter in most cases but the performance difference is pretty noticable
in the Vala compiler itself as we create hundred thousands of GObjects
there.

There is no semantic difference whether you set non-construct properties
with g_object_new or after the call, as it's the last part of
construction, anyway.

Jürg




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