Review Request 122109: Cache QMetaMethods that are invoked on hot paths.

Volker Krause vkrause at kde.org
Sat Jan 17 17:37:54 UTC 2015



> On Jan. 17, 2015, 5:26 p.m., Milian Wolff wrote:
> > src/krecursivefilterproxymodel.cpp, line 60
> > <https://git.reviewboard.kde.org/r/122109/diff/1/?file=342437#file342437line60>
> >
> >     I'd personally move the indexOfMethod + method call into a static free function and use it here and below to share some code.
> >     
> >         QMetaMethod findMethod(const QObject* object, const char* signature)
> >         {
> >             int idx = object->metaObject()->indexOfMethod(signature);
> >             Q_ASSERT(idx != -1);
> >             return object->metaObject()->method(idx);
> >         }
> >         
> >         ...
> >         
> >         static const QMetaMethod method = findMethod(q, "_q_sourceDataChanged(...)");

Makes sense, I'll add that. Thanks!


- Volker


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/122109/#review74187
-----------------------------------------------------------


On Jan. 17, 2015, 5:22 p.m., Volker Krause wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/122109/
> -----------------------------------------------------------
> 
> (Updated Jan. 17, 2015, 5:22 p.m.)
> 
> 
> Review request for KDE Frameworks and Milian Wolff.
> 
> 
> Repository: kitemmodels
> 
> 
> Description
> -------
> 
> QMetaObject::invokeMethod calls QMetaObject::indexForMethod internally,
> which is rather expensive. So look up the method once, and invoke it
> via QMetaMethod directly.
> 
> 
> Diffs
> -----
> 
>   src/krecursivefilterproxymodel.cpp 241f2e8e7e610c397bebc6608a64e4f12e570aea 
> 
> Diff: https://git.reviewboard.kde.org/r/122109/diff/
> 
> 
> Testing
> -------
> 
> Tested and measured with the KRFPM usage in GammaRay, saves about 5% of total application CPU cost according to callgrind.
> 
> 
> Thanks,
> 
> Volker Krause
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20150117/b33c45e4/attachment.html>


More information about the Kde-frameworks-devel mailing list