diff options
| author | Austin Hellyer <[email protected]> | 2016-11-26 11:33:28 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-26 11:33:28 -0800 |
| commit | 23f1dc823d658ee66a51388b742b0d06c94560c9 (patch) | |
| tree | 6b4ccf467d31d45f1e8d6834fdda5bbb18c865f8 /src/model/utils.rs | |
| parent | Remove the 'extras' feature flag (diff) | |
| download | serenity-23f1dc823d658ee66a51388b742b0d06c94560c9.tar.xz serenity-23f1dc823d658ee66a51388b742b0d06c94560c9.zip | |
Make Cache::get_channel return a reference
Additionally, allow it to search the groups' and private channels' maps
in the cache. As these are usually O(1) operations, it's cheap to allow,
in comparison to the current unoptimized method of getting a guild's
channel.
Diffstat (limited to 'src/model/utils.rs')
| -rw-r--r-- | src/model/utils.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/model/utils.rs b/src/model/utils.rs index 23fdfc5..d4ee1c3 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -21,6 +21,8 @@ use ::utils::{decode_array, into_array}; use super::permissions::{self, Permissions}; #[cfg(all(feature = "cache", feature = "methods"))] use ::client::CACHE; +#[cfg(all(feature = "cache", feature = "methods"))] +use ::ext::cache::ChannelRef; #[macro_escape] macro_rules! missing { @@ -284,10 +286,10 @@ pub fn user_has_perms(channel_id: ChannelId, }; let guild_id = match channel { - Channel::Group(_) | Channel::Private(_) => { + ChannelRef::Group(_) | ChannelRef::Private(_) => { return Ok(permissions == permissions::MANAGE_MESSAGES); }, - Channel::Guild(channel) => channel.guild_id, + ChannelRef::Guild(channel) => channel.guild_id, }; let guild = match cache.get_guild(guild_id) { |