<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic"
href="https://bugs.webkit.org/show_bug.cgi?id=147667#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic"
href="https://bugs.webkit.org/show_bug.cgi?id=147667">bug 147667</a>
from <span class="vcard"><a class="email" href="mailto:jmarcell@apple.com" title="Jason Marcell <jmarcell@apple.com>"> <span class="fn">Jason Marcell</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=258244&action=diff" name="attach_258244" title="Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic">attachment 258244</a> <a href="attachment.cgi?id=258244&action=edit" title="Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic">[details]</a></span>
Refactor BuildbotQueue.compareIterations and BuildbotQueue.compareIterationsByRevisions to be more generic
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=258244&action=review">https://bugs.webkit.org/attachment.cgi?id=258244&action=review</a>
<span class="quote">>> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:276
>> + }
>
> Notice that the getter Dashboard.sortedRepositories is called twice on each iteration: once in the for-loop condition "i < Dashboard.sortedRepositories.length" (line 271) and once when evaluating "Dashboard.sortedRepositories[i].name" (line 272). We should cache Dashboard.sortedRepositories and Dashboard.sortedRepositories.length in local variables to avoid extraneous calls to Dashboard.sortedRepositories, such that this for-loop reads:
>
> var sortedRepositories = Dashboard.sortedRepositories;
> for (var i = 0, length = sortedRepositories.length; i < sortedRepositories.length; ++i) {
> var repositoryName = sortedRepositories[i].name;
> var result = b.revision[repositoryName] - a.revision[repositoryName];
> if (result)
> return result;
> }</span >
I tried to do the caching in the getter itself. Does this not cache the sortedRepositories using an instance variable?
get sortedRepositories()
{
if (this._sortedRepositories === undefined) {
this._sortedRepositories = this._sortedItems(Dashboard.Repository);
}
return this._sortedRepositories;
},</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>