Mercurial > hg-stable
changeset 24688:897a0715ee71
subrepo: use vfs.readdir instead of os.listdir to avoid expensive stat calls
"kind" information given from "vfs.readdir()" makes expensive stat
calls "os.path.isdir()" and "os.path.islink()" useless.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 11 Apr 2015 00:47:09 +0900 |
parents | 28d76bc069db |
children | ca3a90096c95 |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Fri Apr 10 08:05:50 2015 +0300 +++ b/mercurial/subrepo.py Sat Apr 11 00:47:09 2015 +0900 @@ -1632,11 +1632,11 @@ # local-only history self.ui.note(_('removing subrepo %s\n') % self._relpath) self._gitcommand(['config', 'core.bare', 'true']) - for f in os.listdir(self._abspath): + for f, kind in self.wvfs.readdir(): if f == '.git': continue path = os.path.join(self._abspath, f) - if os.path.isdir(path) and not os.path.islink(path): + if kind == stat.S_IFDIR: shutil.rmtree(path) else: os.remove(path)