Optimise tight loops in DiscordGateway.received_message

* type(x) is y is faster than isinstance(x, y)
* Re-arrange if-statements for common statements
* Drop handler getattr for most events that don't  use it
This commit is contained in:
Rapptz
2018-09-24 23:22:49 -04:00
parent 095f0ec2fc
commit 2721689254
4 changed files with 55 additions and 46 deletions

View File

@ -124,7 +124,8 @@ class AutoShardedClient(Client):
raise ClientException('shard_ids parameter must be a list or a tuple.')
self._connection = AutoShardedConnectionState(dispatch=self.dispatch, chunker=self._chunker,
syncer=self._syncer, http=self.http, loop=self.loop, **kwargs)
handlers=self._handlers, syncer=self._syncer,
http=self.http, loop=self.loop, **kwargs)
# instead of a single websocket, we have multiple
# the key is the shard_id