<table><tr><td style="">apol added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D22087">View Revision</a></tr></table><br /><div><div><p>+1 overall</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128579">View Inline</a><span style="color: #4b4d51; font-weight: bold;">powermanagementengine.cpp:442</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">uint</span> <span class="n">unnamedBatteries</span> <span style="color: #aa2211">=</span> <span style="color: #601200">0</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">for<span class="bright">each</span></span> <span class="p">(</span><span class="n">QString</span> <span class="n">source<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span class="n">m_batterySources</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span class="n">QString</span> <span style="color: #a0a000">source<span class="bright"></span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span><span class="bright"> </span><span class="n"><span class="bright">qAsConst</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="n">m_batterySources<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">)</span>)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">DataContainer</span> <span style="color: #aa2211">*</span><span class="n">batteryDataContainer</span> <span style="color: #aa2211">=</span> <span class="n">containerForSource</span><span class="p">(</span><span class="n">source</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const &</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128580">View Inline</a><span style="color: #4b4d51; font-weight: bold;">shareengine.cpp:54</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QMultiMap</span><span style="color: #aa2211"><</span><span style="color: #aa4000">int</span><span class="p">,</span> <span class="n">KService</span><span style="color: #aa2211">::</span><span class="n">Ptr</span><span style="color: #aa2211">></span> <span class="n">sortedServices</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">for<span class="bright">each</span></span> <span class="p">(</span><span class="n">KService</span><span style="color: #aa2211">::</span><span class="n">Ptr</span> <span class="n">service<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">services</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span class="n">KService</span><span style="color: #aa2211">::</span><span class="n">Ptr</span> <span style="color: #a0a000">service<span class="bright"></span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span> <span class="n">services</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">sortedServices</span><span class="p">.</span><span class="n">insert</span><span class="p">(</span><span class="n">service</span><span style="color: #aa2211">-></span><span class="n">property</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"X-KDE-Priority"</span><span class="p">)).</span><span class="n">toInt</span><span class="p">(),</span> <span class="n">service</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const &</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128581">View Inline</a><span style="color: #4b4d51; font-weight: bold;">dbusmenushortcut_p.cpp:60</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QStringList</span> <span class="n">tokens</span> <span style="color: #aa2211">=</span> <span class="n">string</span><span class="p">.</span><span class="n">split</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">", "</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span class="n"><span class="bright">Q_FOREACH</span></span><span class="p">(</span><span class="n">QString</span> <span class="n">token<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">tokens</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QStringList</span> <span class="n">tokens</span> <span style="color: #aa2211">=</span> <span class="n">string</span><span class="p">.</span><span class="n">split</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">", "</span><span class="p">));</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p">(</span><span class="n">QString</span> <span style="color: #a0a000">token<span class="bright"></span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span> <span class="n">tokens</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #74777d">// Hack: Qt::CTRL | Qt::Key_Plus is turned into the string "Ctrl++",</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const &, also this should possibly be transformed into a splitRef.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128582">View Inline</a><span style="color: #4b4d51; font-weight: bold;">dbusmenushortcut_p.cpp:75</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QStringList</span> <span class="n">tmp</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span class="n"><span class="bright">Q_FOREACH</span></span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QStringList</span><span style="color: #aa2211">&</span> <span class="n">keyTokens_<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211">*</span><span style="color: #aa4000">this</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p">(</span><span style="color: #aa4000">const</span> <span class="n">QStringList</span><span style="color: #aa2211">&</span> <span style="color: #a0a000">keyTokens_<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">:</span></span><span class="bright"> </span><span class="n"><span class="bright">qAsConst</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span style="color: #aa2211">*</span><span style="color: #aa4000">this<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">)</span>)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QStringList</span> <span class="n">keyTokens</span> <span style="color: #aa2211">=</span> <span class="n">keyTokens_</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">this is already const, no?</p>
<p style="padding: 0; margin: 8px;">weirdest foreach in KDE xD 🏅</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128583">View Inline</a><span style="color: #4b4d51; font-weight: bold;">bookmarksrunner.cpp:86</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">BookmarkMatch</span><span style="color: #aa2211">></span> <span class="n">matches</span> <span style="color: #aa2211">=</span> <span class="n">m_browser</span><span style="color: #aa2211">-></span><span class="n">match</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">allBookmarks</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">for<span class="bright">each</span></span><span class="p">(</span><span class="n">BookmarkMatch</span> <span class="n">match<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">matches</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">BookmarkMatch</span><span style="color: #aa2211">></span> <span class="n">matches</span> <span style="color: #aa2211">=</span> <span class="n">m_browser</span><span style="color: #aa2211">-></span><span class="n">match</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">allBookmarks</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for<span class="bright"></span></span><span class="bright"> </span><span class="p">(</span><span class="n">BookmarkMatch</span> <span style="color: #a0a000">match<span class="bright"></span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span> <span class="n">matches</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">if</span><span class="p">(</span><span style="color: #aa2211">!</span><span class="n">context</span><span class="p">.</span><span class="n">isValid</span><span class="p">())</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const &?</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128584">View Inline</a><span style="color: #4b4d51; font-weight: bold;">chrome.cpp:54</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span class="n"><span class="bright">foreach</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">Profile</span></span> <span class="n">profile<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">findProfile</span><span style="color: #aa2211">-></span><span class="n">find</span><span class="p">()<span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">auto</span></span> <span class="n">profile<span class="bright">s</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span> <span class="n">findProfile</span><span style="color: #aa2211">-></span><span class="n">find</span><span class="p">()<span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span class="n">Profile</span> <span style="color: #a0a000">profile</span> <span class="p">:</span> <span class="n">profiles</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">m_profileBookmarks</span> <span style="color: #aa2211"><<</span> <span style="color: #aa4000">new</span> <span class="n">ProfileBookmarks</span><span class="p">(</span><span class="n">profile</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const&?</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128585">View Inline</a><span style="color: #4b4d51; font-weight: bold;">firefox.cpp:102</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QVariantMap</span><span style="color: #aa2211">></span> <span class="n">results</span> <span style="color: #aa2211">=</span> <span class="n">m_fetchsqlite</span><span style="color: #aa2211">-></span><span class="n">query</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">QMap</span><span style="color: #aa2211"><</span><span class="n">QString</span><span class="p">,</span> <span class="n">QVariant</span><span style="color: #aa2211">></span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span class="n">QList</span><span style="color: #aa2211"><</span><span class="n">QVariantMap</span><span style="color: #aa2211">></span> <span class="n">results</span> <span style="color: #aa2211">=</span> <span class="n">m_fetchsqlite</span><span style="color: #aa2211">-></span><span class="n">query</span><span class="p">(</span><span class="n">query</span><span class="p">,</span> <span class="n">QMap</span><span style="color: #aa2211"><</span><span class="n">QString</span><span class="p">,</span> <span class="n">QVariant</span><span style="color: #aa2211">></span><span class="p">());</span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="n">QMultiMap</span><span style="color: #aa2211"><</span><span class="n">QString</span><span class="p">,</span> <span class="n">QString</span><span style="color: #aa2211">></span> <span class="n">uniqueResults</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="n">for<span class="bright">each</span></span><span class="p">(</span><span class="n">QVariantMap</span> <span class="n">result<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">results</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for<span class="bright"></span></span><span class="bright"> </span><span class="p">(</span><span class="n">QVariantMap</span> <span style="color: #a0a000">result<span class="bright"></span></span><span class="bright"> </span><span class="p"><span class="bright">:</span></span> <span class="n">results</span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const &</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D22087#inline-128586">View Inline</a><span style="color: #4b4d51; font-weight: bold;">screenpool.cpp:174</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #74777d">//m_connectorForId is the only map, so the ids are sorted</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span class="n"><span class="bright">foreach</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">int</span></span><span class="bright"> </span><span class="n"><span class="bright">existingId</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span> <span class="n">m_connectorForId</span><span class="p">.</span><span class="n">keys</span><span class="p">()<span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">auto</span></span><span class="bright"> </span><span class="n"><span class="bright">keys</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span> <span class="n">m_connectorForId</span><span class="p">.</span><span class="n">keys</span><span class="p">()<span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span style="color: #aa4000">int</span> <span style="color: #a0a000">existingId</span> <span class="p">:</span> <span class="n">keys</span><span class="p">)</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Iterating through keys isn't very optimal, I'd use iterators here.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D22087">https://phabricator.kde.org/D22087</a></div></div><br /><div><strong>To: </strong>nicolasfella, Plasma<br /><strong>Cc: </strong>apol, plasma-devel, LeGast00n, jraleigh, fbampaloukas, GB_2, ragreen, Pitel, ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, mart<br /></div>