[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:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2006-10-15 12:39:35
Message-ID: 200610151439.39755.kevin.krammer () gmx ! at
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Sunday 15 October 2006 11:10, Thomas Zander wrote:
> 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.

Taking Qt itself as an example, they copy on return and use const-ref on call, 
for example
QLineEdit::text() returns a QString, so it copies, while QLineEdit::setText() 
takes a const QString&

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer
KDE user support, developer mentoring

[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