From ab030ae52871e99b6069ef511e082665c5dca0fd Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Sun, 28 Aug 2022 10:45:57 +0300 Subject: [PATCH] Little bit faster. #24 cpburnz/python-path-specification#38 --- gitignorefile/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitignorefile/__init__.py b/gitignorefile/__init__.py index 5769841..cabd8dc 100644 --- a/gitignorefile/__init__.py +++ b/gitignorefile/__init__.py @@ -110,10 +110,11 @@ def _handle_negation(file_path, rules, base_path=None, is_dir=None): matched = False for rule in rules: if rule.match(rel_path, is_dir): - matched = not rule.negation - if matched and return_immediately: + if return_immediately: return True + matched = not rule.negation + else: return matched