changelog: tonodes(idset) has a fast path

Summary:
By default, `torevs` calls Python iteration for non-list, non-spans Python
objects. The `idset` object has the `spans` which can be used as a fast
path.

Reviewed By: DurhamG

Differential Revision: D22970580

fbshipit-source-id: f491404ba803c4468c17cd74daaea90f46b8b38b
This commit is contained in:
Jun Wu 2020-08-20 17:13:50 -07:00 committed by Jun Wu
parent 1649714542
commit e5d816c812

View File

@ -17,6 +17,7 @@ from . import (
mdiff, mdiff,
progress, progress,
revlog, revlog,
smartset,
util, util,
visibility, visibility,
) )
@ -147,10 +148,12 @@ class changelog(object):
""" """
return self.inner.torevs return self.inner.torevs
@property def tonodes(self, revs):
def tonodes(self):
"""Convert an IdSet to Set. The reverse of torevs.""" """Convert an IdSet to Set. The reverse of torevs."""
return self.inner.tonodes # 'idset' has a fast path - pass the Rust-binding 'spans' directly.
if isinstance(revs, smartset.idset):
return self.inner.tonodes(revs._spans)
return self.inner.tonodes(revs)
def _loadvisibleheads(self, svfs): def _loadvisibleheads(self, svfs):
return visibility.visibleheads(svfs) return visibility.visibleheads(svfs)