~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/branchcollection.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-09-02 01:59:36 UTC
  • mfrom: (13827.1.3 bug724025)
  • Revision ID: launchpad@pqm.canonical.com-20110902015936-3faztvdzym6qtyje
[r=jtv][bug=724025] implement some low-hanging optimizations when a
        bug has many branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    With,
25
25
    )
26
26
from storm.info import ClassAlias
 
27
from storm.store import EmptyResultSet
27
28
from zope.component import getUtility
28
29
from zope.interface import implements
29
30
 
280
281
                          target_branch=None, merged_revnos=None,
281
282
                          eager_load=False):
282
283
        """See `IBranchCollection`."""
283
 
        if (self._asymmetric_filter_expressions or for_branches or
284
 
            target_branch or merged_revnos):
 
284
        if for_branches is not None and not for_branches:
 
285
            # We have an empty branches list, so we can shortcut.
 
286
            return EmptyResultSet()
 
287
        elif merged_revnos is not None and not merged_revnos:
 
288
            # We have an empty revnos list, so we can shortcut.
 
289
            return EmptyResultSet()
 
290
        elif (self._asymmetric_filter_expressions or
 
291
            for_branches is not None or
 
292
            target_branch is not None or
 
293
            merged_revnos is not None):
285
294
            return self._naiveGetMergeProposals(statuses, for_branches,
286
295
                target_branch, merged_revnos, eager_load)
287
296
        else: