[Interest] How to speed-up chameleons

Keith Gardner kreios4004 at gmail.com
Wed Jun 11 15:36:15 CEST 2014


>
> I have one question to you. Why new syntax of QObject::connect() improve
> performance for a 5%.
>
> I mean that if in code change
>
> connect( sender, SIGNAL( signal() ), receiver, SLOT( slot() ) );
>
> to
>
> connect( sender, &Sender::signal, receiver, &Receiver::slot );
>
> then code works faster... Why? May be somebody know the answer, I don’t
> want to read Qt’s code for the answer on this question.
>

I would guess would be that the first connect is performing a string lookup
and validating the arguments at run time.  SIGNAL and SLOT are taking the
macro parameters and turning them into character arrays.

The second connect is working with function pointers which allows for the
compiler validate their existence and ensure that the arguments are
compatible at compile time instead of run time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140611/4038b306/attachment.html>


More information about the Interest mailing list