From 3d03dbc45179f645b59838729047e896cc387049 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 24 Sep 2018 21:05:41 -0400 Subject: Change internal role storage in Guild to a dict instead of a list. This adds the following APIs: * Guild.get_role This removes the following APIs: * Guild.role_hierarchy To compensate for the removed APIs, Guild.roles is now a sorted list based on hierarchy. The first element will always be the @everyone role. This speeds up access at the cost of some memory, theoretically. --- discord/abc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'discord/abc.py') diff --git a/discord/abc.py b/discord/abc.py index 0ca11452..8482104a 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -288,8 +288,9 @@ class GuildChannel: """Returns a :class:`list` of :class:`Roles` that have been overridden from their default values in the :attr:`Guild.roles` attribute.""" ret = [] + g = self.guild for overwrite in filter(lambda o: o.type == 'role', self._overwrites): - role = utils.get(self.guild.roles, id=overwrite.id) + role = g.get_role(overwrite.id) if role is None: continue @@ -358,8 +359,7 @@ class GuildChannel: overwrite = PermissionOverwrite.from_pair(allow, deny) if ow.type == 'role': - # accidentally quadratic - target = utils.find(lambda r: r.id == ow.id, self.guild.roles) + target = self.guild.get_role(ow.id) elif ow.type == 'member': target = self.guild.get_member(ow.id) -- cgit v1.2.3