[Kde-pim] [patch] handling of static data in akonadi and mailtransport
Ingo Klöcker
kloecker at kde.org
Mon May 19 20:12:59 BST 2008
On Monday 19 May 2008, Jarosław Staniek wrote:
> -SmtpJob: added reverse hash so we don't need to perform linear
> lookup in slavePool
That's not really worth the effort and the additional memory
allocations. In fact, a linear lookup on such a small number of
elements is often more efficient.
> Index: mailtransport/socket.cpp
> ===================================================================
> --- mailtransport/socket.cpp (wersja 809610)
> +++ mailtransport/socket.cpp (kopia robocza)
> @@ -102,7 +102,7 @@
> return;
> }
>
> - static QString msg;
> + QString msg;
> msg += QLatin1String( socket->readAll() );
>
> if ( !msg.endsWith( QLatin1Char( '\n' ) ) ) {
This change is clearly wrong because the full code of this method reads:
=====
void SocketPrivate::slotSocketRead()
{
kDebug();
if ( !socket ) {
return;
}
static QString msg;
msg += QLatin1String( socket->readAll() );
if ( !msg.endsWith( QLatin1Char( '\n' ) ) ) {
return;
}
#ifdef comm_debug
kDebug() << socket->isEncrypted() << msg.trimmed();
#endif
emit q->data( msg );
msg.clear();
}
=====
So text is appended to the static QString msg until msg ends with '\n'.
Your patch will make the socket lose all text that does not end
with '\n'. Of course, there are much better ways than to use a static
QString for this, e.g. a member variable.
Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20080519/8b17d02f/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
More information about the kde-pim
mailing list