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/id.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/id.rs')
| -rw-r--r-- | src/model/id.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/model/id.rs b/src/model/id.rs index 7cc4f31..cba72ae 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -11,7 +11,7 @@ impl ChannelId { /// Search the cache for the channel with the Id. #[cfg(all(feature = "cache", feature = "methods"))] pub fn find(&self) -> Option<Channel> { - CACHE.read().unwrap().get_channel(*self) + CACHE.read().unwrap().get_channel(*self).map(|x| x.clone_inner()) } /// Search the cache for the channel. If it can't be found, the channel is @@ -20,7 +20,7 @@ impl ChannelId { pub fn get(&self) -> Result<Channel> { feature_cache_enabled! {{ if let Some(channel) = CACHE.read().unwrap().get_channel(*self) { - return Ok(channel.clone()); + return Ok(channel.clone_inner()); } }} |