[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] kabc question
From:       Reinhold Kainhofer <kde () kainhofer ! com>
Date:       2002-05-28 22:05:41
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Dienstag, 28. Mai 2002 22:33 schrieb Cornelius Schumacher:
> > Can't we introduce a startNoDetach() and an endNoDetach() function to
> > prevent this kind of unnecessary copying from taking place? (or
> > invent some other way to set multiple data fields at once without
> > detach()ing)
>
> What about the attached patch?

Ahh, obvious thing, of course. Could have thought of that myself. 

If you use something like 

void setEmail(KABC::Addressee a, QString mail) { a->insertEmail(mail); }

void doSync(...) {....
	setEmail(myAddressee, "test@domain.tld");
	setEmail( myAddressee, "test2@another.domain.tld");
}

doesn't the by-value call to setEmail create a copy of the myAddressee? (You 
see, my theoretical C++ knowledge is not so profound, it's just what I 
remember from reading Stroustrup some long time ago). If so, does a 
definition like

void setEmail(KABC::Addressee &a, QString mail) {...}

prevent this, since the Addressee is passed by reference? If so, with your 
patch one really needs to take care to use the &a in all methods!

I still think your patch is the correct and clean solution to the problem, we 
just need to make sure developers understand that they need to pass by 
reference if they don't want to do some unnecessary stuff.

Reinhold
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE88/82TqjEwhXvPN0RAif1AKCoMSNOTAYt1SQAwHya27vyXQtAaQCfT+os
6dyf07eMVG4H4JSGPJF1RIg=
=NyWH
-----END PGP SIGNATURE-----
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic