match: make differencematcher.visitdir slightly more efficient

Summary:
At the moment differencematcher.visitdir never returns "all".

This diff changes it to return all in the case if self._m2 doesn't visit the directory at all and
self.m1.visitdir(dir) returns "all". This makes sense - if m1 visits all files
in the directory and m2 doesn't exclude any file then it's safe to return all
in this case.

This optimization will be used in the next diff.

Reviewed By: sfilipco

Differential Revision: D24725903

fbshipit-source-id: 2a049cfb1ea4878331e8640cbb20af74da86a1a1
This commit is contained in:
Stanislau Hlebik 2020-11-05 04:37:49 -08:00 committed by Facebook GitHub Bot
parent 5b92b6978e
commit abfe3d84c7

View File

@ -1050,6 +1050,9 @@ class differencematcher(basematcher):
def visitdir(self, dir):
dir = normalizerootdir(dir, "visitdir")
if not self._m2.visitdir(dir):
return self._m1.visitdir(dir)
if self._m2.visitdir(dir) == "all":
# There's a bug here: If m1 matches file 'dir/file' and m2 excludes
# 'dir' (recursively), we should still visit 'dir' due to the