From patchwork Wed Sep 17 16:36:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: revset: document the choice made in _generatorset.__iter__ From: Pierre-Yves David X-Patchwork-Id: 5851 Message-Id: To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Wed, 17 Sep 2014 09:36:34 -0700 # HG changeset patch # User Pierre-Yves David # Date 1410936161 25200 # Tue Sep 16 23:42:41 2014 -0700 # Node ID e282c07bac1a5627920f53bd8b233a55ce42d05d # Parent a476ee0b8e799c1b9b82ad2db350c90a31274879 revset: document the choice made in _generatorset.__iter__ The method code looks a bit ugly but have good reason to do so. We document them to prevent naive refactoring in the future. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2646,10 +2646,16 @@ class _generatorset(object): if self._finished: for x in self._genlist: yield x return + # we have to use this complexe iteration strategy to allow multiple + # iteration at the same time. We need to be able to catch revision + # removed from `consumegen` and added to genlist in another instance. + # + # Getting ride of it would provide an about 15% speed up on this + # iteration. i = 0 genlist = self._genlist consume = self._consumegen() while True: if i < len(genlist):