main: better name for _collection_node_cache3

The weird name was due to f3967333a1, now
that I understand it a bit better can give it a more descriptive name.
This commit is contained in:
Ran Benita 2020-08-21 17:03:52 +03:00
parent c2256189ae
commit c4fd461617
1 changed files with 8 additions and 6 deletions

View File

@ -454,7 +454,10 @@ class Session(nodes.FSCollector):
self._collection_node_cache2 = ( self._collection_node_cache2 = (
{} {}
) # type: Dict[Tuple[Type[nodes.Collector], py.path.local], nodes.Collector] ) # type: Dict[Tuple[Type[nodes.Collector], py.path.local], nodes.Collector]
self._collection_node_cache3 = (
# Keep track of any collected collectors in matchnodes paths, so they
# are not collected more than once.
self._collection_matchnodes_cache = (
{} {}
) # type: Dict[Tuple[Type[nodes.Collector], str], CollectReport] ) # type: Dict[Tuple[Type[nodes.Collector], str], CollectReport]
@ -652,7 +655,7 @@ class Session(nodes.FSCollector):
self.trace.root.indent -= 1 self.trace.root.indent -= 1
self._collection_node_cache1.clear() self._collection_node_cache1.clear()
self._collection_node_cache2.clear() self._collection_node_cache2.clear()
self._collection_node_cache3.clear() self._collection_matchnodes_cache.clear()
self._collection_pkg_roots.clear() self._collection_pkg_roots.clear()
def _collect( def _collect(
@ -677,7 +680,6 @@ class Session(nodes.FSCollector):
if col: if col:
if isinstance(col[0], Package): if isinstance(col[0], Package):
self._collection_pkg_roots[str(parent)] = col[0] self._collection_pkg_roots[str(parent)] = col[0]
# Always store a list in the cache, matchnodes expects it.
self._collection_node_cache1[col[0].fspath] = [col[0]] self._collection_node_cache1[col[0].fspath] = [col[0]]
# If it's a directory argument, recurse and look for any Subpackages. # If it's a directory argument, recurse and look for any Subpackages.
@ -761,11 +763,11 @@ class Session(nodes.FSCollector):
if not isinstance(node, nodes.Collector): if not isinstance(node, nodes.Collector):
continue continue
key = (type(node), node.nodeid) key = (type(node), node.nodeid)
if key in self._collection_node_cache3: if key in self._collection_matchnodes_cache:
rep = self._collection_node_cache3[key] rep = self._collection_matchnodes_cache[key]
else: else:
rep = collect_one_node(node) rep = collect_one_node(node)
self._collection_node_cache3[key] = rep self._collection_matchnodes_cache[key] = rep
if rep.passed: if rep.passed:
submatching = [] submatching = []
for x in rep.result: for x in rep.result: