Skip to content

Commit b718450

Browse files
committed
Optimize get_commands filtering to single pass
1 parent 0a315d1 commit b718450

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

src/commands.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,12 @@ def get_commands(
7070
include_plugin_commands: bool = True,
7171
include_skill_commands: bool = True,
7272
) -> tuple[PortingModule, ...]:
73-
commands = list(PORTED_COMMANDS)
74-
if not include_plugin_commands:
75-
commands = [
76-
module for module in commands if "plugin" not in module.source_hint.lower()
77-
]
78-
if not include_skill_commands:
79-
commands = [
80-
module for module in commands if "skills" not in module.source_hint.lower()
81-
]
82-
return tuple(commands)
73+
return tuple(
74+
module
75+
for module in PORTED_COMMANDS
76+
if (include_plugin_commands or "plugin" not in module.source_hint.lower())
77+
and (include_skill_commands or "skills" not in module.source_hint.lower())
78+
)
8379

8480

8581
def find_commands(query: str, limit: int = 20) -> list[PortingModule]:

0 commit comments

Comments
 (0)