Hi Gerrit,
Carsten Neumann wrote:
> Hi Gerrit,
>
> Gerrit Voss wrote:
>> Hi,
>> I'm thinking of changing the getFoo field access functions to readFoo.
>>
>> The main reason is that with OSG_1_COMPAT enabled there are a lot of
>> unnecessary changes recorded (internally during rendering), because
>> the compiler selects the wrong, non const, get. Which means the
>> performance is dreadful.
>>
>>> >From the two options,
>>
>> 1) chasing down all the locations and make sure the const version
>> is used
>> and
>> 2) change getFoo to readFoo to make sure internally no unnecessary
>> changes are recorded
>>
>> I'm currently leaning towards 2). Main reason is it will catch
>> everything at once (at least internal). 1) will be a constant battle.
>> Any opinions ??
>
> just let me summarize this, to see if I get the implications right, for
> option 2) we would get the following, yes?
>
> readFoo() const;
> editFoo();
>
> #ifdef OSG_1_COMPAT
> getFoo() const;
> getFoo();
> #endif
... in addition to
setFoo();
which is why I'm not excited about the change, as it would kill the get/set
parallelism. Besides that, read is longer than get. So an alternative would be:
3) replace getFoo() with foo() (no verb), which is similar to Performer (just
the other way around) and avoids the length problem.
I've been playing with it a little bit, and it seems at least g++ is not very
smart about picking the right version, unless the object is const it always
picks the non-const method. :( So besides going through the source tree with a
fine-toothed comb to make sure absolutely everything that can be const is const
that won't help us. It wouldn't hurt to be more diligent about const in
general,
but I don't know if we want to tackle this right now.
The problem arises because by default we return references to everything, to
avoid copying large object types needlessly. However, most of our types are
small enough that it's not a big deal to create copies (mostly built-in types
or
FCPtr). Personally I have never used the ability to change the value using the
reference passed by get(), so I wouldn't mind going for this one:
4) Remove getFoo();, only keep getFoo() const. This would bomb with (some) old
code. I'm not sure with how much old code, but I think very little. This would
need to be queried from the users though. It would break backwards compat, but
if the cost of keeping it is prohibitive there's no point keeping it if it will
make the new interface worse.
5) (Equivalent to 4) Change getFoo() to return an actual value and only have
edit return a reference. Honestly I don't know if compilers are smart enough to
make 4) and 5) the same code or if they do a deref on refs anyway. But IMHO
returning actual values is cleaner than returning refs for everything.
Comments?
Dirk
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core