aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-12-27 18:29:34 +0100
committeracdenisSK <[email protected]>2017-12-27 18:33:29 +0100
commit3a0c8908ce837f6fe64f865a1a7a9de63cbd237c (patch)
treea8597bb4a7d49cfd614a85d3f2b5a95d3df9e055 /src/utils
parentUpdate dependencies (diff)
downloadserenity-3a0c8908ce837f6fe64f865a1a7a9de63cbd237c.tar.xz
serenity-3a0c8908ce837f6fe64f865a1a7a9de63cbd237c.zip
Improve performance of builders even further
By negating hashing altogether. The increase is around 1000-ish nanoseconds saved.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 907d3a3..74d37de 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -11,6 +11,7 @@ pub use self::message_builder::{Content, ContentModifier, MessageBuilder};
#[cfg(feature = "builder")]
pub use super::builder;
+use builder::VecMap;
use base64;
use internal::prelude::*;
use model::id::EmojiId;
@@ -39,6 +40,17 @@ pub fn hashmap_to_json_map<H, T>(map: HashMap<T, Value, H>)
json_map
}
+/// Converts a VecMap into a final `serde_json::Map` representation.
+pub fn vecmap_to_json_map<K: PartialEq + ToString>(map: VecMap<K, Value>) -> Map<String, Value> {
+ let mut json_map = Map::new();
+
+ for (key, value) in map {
+ json_map.insert(key.to_string(), value);
+ }
+
+ json_map
+}
+
/// Determines if a name is NSFW.
///
/// This checks that the name is either `"nsfw"` or, for names longer than that,