From 7a018615b63a3319714b185d95cefb58eee07d26 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 17 Feb 2020 12:27:25 -0500 Subject: [PATCH] Extract existing names lookup into a variable once again. Fixes #43. --- zipp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zipp.py b/zipp.py index 2ede259..4122b73 100644 --- a/zipp.py +++ b/zipp.py @@ -68,11 +68,12 @@ class CompleteDirs(zipfile.ZipFile): @staticmethod def _implied_dirs(names): parents = itertools.chain.from_iterable(map(_parents, names)) + # Cast names to a set for O(1) lookups + existing = set(names) # Deduplicate entries in original order implied_dirs = OrderedDict.fromkeys( p + posixpath.sep for p in parents - # Cast names to a set for O(1) lookups - if p + posixpath.sep not in set(names) + if p + posixpath.sep not in existing ) return implied_dirs