<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/122109/">https://git.reviewboard.kde.org/r/122109/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On January 17th, 2015, 5:26 p.m. UTC, <b>Milian Wolff</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://git.reviewboard.kde.org/r/122109/diff/1/?file=342437#file342437line60" style="color: black; font-weight: bold; text-decoration: underline;">src/krecursivefilterproxymodel.cpp</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">public:</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">58</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="n">success</span> <span class="o">=</span> <span class="n">QMetaObject</span><span class="o">::</span><span class="n">invokeMethod</span><span class="p">(</span><span class="n">q</span><span class="p">,</span> <span class="s">"_q_sourceDataChanged"</span><span class="p">,</span> <span class="n">Qt</span><span class="o">::</span><span class="n">DirectConnection</span><span class="p">,</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">60</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "> <span class="k">static</span> <span class="k">const</span> <span class="n">QMetaMethod</span> <span class="n">m</span> <span class="o">=</span> <span class="n">q</span><span class="o">-></span><span class="n">metaObject</span><span class="p">()</span><span class="o">-></span><span class="n">method</span><span class="p">(</span><span class="n">q</span><span class="o">-></span><span class="n">metaObject</span><span class="p">()</span><span class="o">-></span><span class="n">indexOfMethod</span><span class="p">(</span><span class="s">"_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)"</span><span class="p">));</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">I'd personally move the indexOfMethod + method call into a static free function and use it here and below to share some code.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%">QMetaMethod <span style="color: #0000FF">findMethod</span>(<span style="color: #008000; font-weight: bold">const</span> QObject<span style="color: #666666">*</span> object, <span style="color: #008000; font-weight: bold">const</span> <span style="color: #B00040">char</span><span style="color: #666666">*</span> signature)
{
<span style="color: #B00040">int</span> idx <span style="color: #666666">=</span> object<span style="color: #666666">-></span>metaObject()<span style="color: #666666">-></span>indexOfMethod(signature);
Q_ASSERT(idx <span style="color: #666666">!=</span> <span style="color: #666666">-1</span>);
<span style="color: #008000; font-weight: bold">return</span> object<span style="color: #666666">-></span>metaObject()<span style="color: #666666">-></span>method(idx);
}
...
<span style="color: #008000; font-weight: bold">static</span> <span style="color: #008000; font-weight: bold">const</span> QMetaMethod method <span style="color: #666666">=</span> findMethod(q, <span style="color: #BA2121">"_q_sourceDataChanged(...)"</span>);
</pre></div>
</p></pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Makes sense, I'll add that. Thanks!</p></pre>
<br />
<p>- Volker</p>
<br />
<p>On January 17th, 2015, 5:22 p.m. UTC, Volker Krause wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for KDE Frameworks and Milian Wolff.</div>
<div>By Volker Krause.</div>
<p style="color: grey;"><i>Updated Jan. 17, 2015, 5:22 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
kitemmodels
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">QMetaObject::invokeMethod calls QMetaObject::indexForMethod internally,
which is rather expensive. So look up the method once, and invoke it
via QMetaMethod directly.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Tested and measured with the KRFPM usage in GammaRay, saves about 5% of total application CPU cost according to callgrind.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>src/krecursivefilterproxymodel.cpp <span style="color: grey">(241f2e8e7e610c397bebc6608a64e4f12e570aea)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/122109/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>