Skip to content

Commit 4414b25

Browse files
Update codeflash/code_utils/code_utils.py
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
1 parent b7dc7bd commit 4414b25

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

codeflash/code_utils/code_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,20 @@ def create_rank_dictionary_compact(int_array: list[int]) -> dict[int, int]:
8585

8686

8787
def filter_args(addopts_args: list[str]) -> list[str]:
88+
# Convert BLACKLIST_ADDOPTS to a set for faster lookup of simple matches
89+
# But keep tuple for startswith
90+
blacklist = BLACKLIST_ADDOPTS
91+
# Precompute the length for re-use
92+
n = len(addopts_args)
8893
filtered_args = []
8994
i = 0
90-
while i < len(addopts_args):
95+
while i < n:
9196
current_arg = addopts_args[i]
92-
# Check if current argument starts with --cov
93-
if current_arg.startswith(BLACKLIST_ADDOPTS):
94-
# Skip this argument
97+
if current_arg.startswith(blacklist):
9598
i += 1
96-
# Check if the next argument is a value (doesn't start with -)
97-
if i < len(addopts_args) and not addopts_args[i].startswith("-"):
98-
# Skip the value as well
99+
if i < n and not addopts_args[i].startswith("-"):
99100
i += 1
100101
else:
101-
# Keep this argument
102102
filtered_args.append(current_arg)
103103
i += 1
104104
return filtered_args

0 commit comments

Comments
 (0)