aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/guild_id.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-10 20:08:11 -0700
committerZeyla Hellyer <[email protected]>2017-10-10 20:08:11 -0700
commit93e0a4215c915b98cf433ac6d0bcfbc60f0168ec (patch)
tree727111506d1f89cd8a511b8b79c102131222421f /src/model/guild/guild_id.rs
parentResume on resumable session invalidations (diff)
downloadserenity-93e0a4215c915b98cf433ac6d0bcfbc60f0168ec.tar.xz
serenity-93e0a4215c915b98cf433ac6d0bcfbc60f0168ec.zip
Switch to parking_lot::{Mutex, RwLock}
Switch to the `parking_lot` crate's implementations of `std::sync::Mutex` and `std::sync::RwLock`, which are more efficient. A writeup on why `parking_lot` is more efficient can be read here: <https://github.com/Amanieu/parking_lot> Upgrade path: Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to unwrap or handle a result), and `rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to `rwlock.read()` and `rwlock.write()`. For example, modify: ```rust use serenity::CACHE; println!("{}", CACHE.read().unwrap().user.id); ``` to: ```rust use serenity::CACHE; println!("{}", CACHE.read().user.id); ```
Diffstat (limited to 'src/model/guild/guild_id.rs')
-rw-r--r--src/model/guild/guild_id.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs
index 4b9a713..efda6a8 100644
--- a/src/model/guild/guild_id.rs
+++ b/src/model/guild/guild_id.rs
@@ -305,7 +305,7 @@ impl GuildId {
/// Search the cache for the guild.
#[cfg(feature = "cache")]
- pub fn find(&self) -> Option<Arc<RwLock<Guild>>> { CACHE.read().unwrap().guild(*self) }
+ pub fn find(&self) -> Option<Arc<RwLock<Guild>>> { CACHE.read().guild(*self) }
/// Requests the guild over REST.
///
@@ -408,7 +408,7 @@ impl GuildId {
/// [`utils::shard_id`]: ../utils/fn.shard_id.html
#[cfg(all(feature = "cache", feature = "utils"))]
#[inline]
- pub fn shard_id(&self) -> u64 { ::utils::shard_id(self.0, CACHE.read().unwrap().shard_count) }
+ pub fn shard_id(&self) -> u64 { ::utils::shard_id(self.0, CACHE.read().shard_count) }
/// Returns the Id of the shard associated with the guild.
///