aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-03-16 09:27:59 -0400
committerRapptz <[email protected]>2019-03-16 09:27:59 -0400
commit3326adf63b3ba46b24d314a37a8c6f1dbf6ac415 (patch)
treedb3b19f5554362f5134516f1c92139df8c62e0dd
parent[commands] Assign context inside HelpCommand.prepare_help_command (diff)
downloaddiscord.py-3326adf63b3ba46b24d314a37a8c6f1dbf6ac415.tar.xz
discord.py-3326adf63b3ba46b24d314a37a8c6f1dbf6ac415.zip
[commands] Optimise GroupMixin.get_command for the no space case.
Comes at a 30ns slowdown for the space case, however.
-rw-r--r--discord/ext/commands/core.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py
index 6b9b3c9e..30e110da 100644
--- a/discord/ext/commands/core.py
+++ b/discord/ext/commands/core.py
@@ -1015,6 +1015,10 @@ class GroupMixin:
The command that was requested. If not found, returns ``None``.
"""
+ # fast path, no space in name.
+ if ' ' not in name:
+ return self.all_commands.get(name)
+
names = name.split()
obj = self.all_commands.get(names[0])
if not isinstance(obj, GroupMixin):