[prev in list] [next in list] [prev in thread] [next in thread]
List: koffice-devel
Subject: Re: EBN const-ref fixes for krita and libs
From: Thomas Zander <zander () kde ! org>
Date: 2006-10-15 9:10:51
Message-ID: 200610151110.56104.zander () kde ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
On Sunday 15 October 2006 09:48, Boudewijn Rempt wrote:
> > I have the fixes for most of them on my HD (or will soon).
> > I was asked to announce it before I commit the changes.
> > Are there any objections against committing tomorrow afternoon?
>
> I am not sure about this: the Qt documentation says explicitly that objects
> like QImage, QByteArray and QPixmap are implicitly shared, with
> copy-on-write, making it cheap and easy and preferable to pass them by
> value. And wasn't there some thread some time ago on k-c-d about passing
> QString by value being preferred to pass-by-reference nowadays?
The k-c-d thread was about returning a value.
What david told me is that its faster to pass a pointer then to copy the
object, even if its a shared one. Its safe to do so when its an argument
(provided you do a const) but not when returning a value since the object you
are referring to may have gone out of scope.
Now for getters the going out of scope is never a problem (since its a member
var, and not something allocated on the stack) but altering the method
signature for those cases gives away an implementation detail and therefor
breaks encapsulation.
So, I think that if its possible to have a 'const QString &' instead of a
'QString' then its a good idea. If not, then ignore the warning.
This means for example that the KoUnit.cpp one (line 147) should be ignored.
--
Thomas Zander
[Attachment #5 (application/pgp-signature)]
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic