<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&#64;apple.com" title="Jason Marcell &lt;jmarcell&#64;apple.com&gt;"> <span class="fn">Jason Marcell</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=258244&amp;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&amp;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&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=258244&amp;action=review</a>

<span class="quote">&gt;&gt; Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:276
&gt;&gt; +        }
&gt; 
&gt; Notice that the getter Dashboard.sortedRepositories is called twice on each iteration: once in the for-loop condition &quot;i &lt; Dashboard.sortedRepositories.length&quot; (line 271) and once when evaluating &quot;Dashboard.sortedRepositories[i].name&quot; (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:
&gt; 
&gt; var sortedRepositories = Dashboard.sortedRepositories;
&gt; for (var i = 0, length = sortedRepositories.length; i &lt; sortedRepositories.length; ++i) {
&gt;     var repositoryName = sortedRepositories[i].name;
&gt;     var result = b.revision[repositoryName] - a.revision[repositoryName];
&gt;     if (result)
&gt;         return result;
&gt; }</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>