From 276134eb9362b8e0262cb948e8d0eb653dbd2739 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 3 Mar 2020 19:51:02 -0500 Subject: [PATCH] prefer hashmap over btreemap where ordering is unimportant --- src/builtin/color/hsl.rs | 4 ++-- src/builtin/color/mod.rs | 4 ++-- src/builtin/color/opacity.rs | 4 ++-- src/builtin/color/other.rs | 4 ++-- src/builtin/color/rgb.rs | 4 ++-- src/builtin/list.rs | 4 ++-- src/builtin/math.rs | 4 ++-- src/builtin/meta.rs | 4 ++-- src/builtin/mod.rs | 6 +++--- src/builtin/string.rs | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/builtin/color/hsl.rs b/src/builtin/color/hsl.rs index af35247..f8b7906 100644 --- a/src/builtin/color/hsl.rs +++ b/src/builtin/color/hsl.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::color::Color; @@ -6,7 +6,7 @@ use crate::common::QuoteKind; use crate::units::Unit; use crate::value::{Number, Value}; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "hsl", |args, _| { let hue = match arg!(args, 0, "hue") { Value::Dimension(n, _) => n, diff --git a/src/builtin/color/mod.rs b/src/builtin/color/mod.rs index e2f7a27..5822839 100644 --- a/src/builtin/color/mod.rs +++ b/src/builtin/color/mod.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; @@ -7,7 +7,7 @@ mod opacity; mod other; mod rgb; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { hsl::register(f); opacity::register(f); other::register(f); diff --git a/src/builtin/color/opacity.rs b/src/builtin/color/opacity.rs index ffa3027..42cf4db 100644 --- a/src/builtin/color/opacity.rs +++ b/src/builtin/color/opacity.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::common::QuoteKind; @@ -6,7 +6,7 @@ use crate::units::Unit; use crate::value::Number; use crate::value::Value; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "alpha", |args, _| { max_args!(args, 1); match arg!(args, 0, "color") { diff --git a/src/builtin/color/other.rs b/src/builtin/color/other.rs index 51e49ff..03faa76 100644 --- a/src/builtin/color/other.rs +++ b/src/builtin/color/other.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::color::Color; @@ -35,7 +35,7 @@ macro_rules! opt_arg { }; } -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "change-color", |args, _| { if args.get("1").is_some() { return Err("Only one positional argument is allowed. All other arguments must be passed by name.".into()); diff --git a/src/builtin/color/rgb.rs b/src/builtin/color/rgb.rs index df56967..ad38c59 100644 --- a/src/builtin/color/rgb.rs +++ b/src/builtin/color/rgb.rs @@ -1,11 +1,11 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::color::Color; use crate::units::Unit; use crate::value::{Number, Value}; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "rgb", |args, _| { if args.len() == 1 { let mut channels = match arg!(args, 0, "channels") { diff --git a/src/builtin/list.rs b/src/builtin/list.rs index 96d5a95..992ddf8 100644 --- a/src/builtin/list.rs +++ b/src/builtin/list.rs @@ -1,10 +1,10 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::units::Unit; use crate::value::{Number, Value}; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "length", |args, _| { let len = match arg!(args, 0, "list") { Value::List(v, _) => Number::from(v.len()), diff --git a/src/builtin/math.rs b/src/builtin/math.rs index 1f6e6cf..7a30b18 100644 --- a/src/builtin/math.rs +++ b/src/builtin/math.rs @@ -1,10 +1,10 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::Builtin; use crate::units::Unit; use crate::value::{Number, Value}; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "percentage", |args, _| { max_args!(args, 1); let num = match arg!(args, 0, "number") { diff --git a/src/builtin/meta.rs b/src/builtin/meta.rs index a0d9bef..ebefa98 100644 --- a/src/builtin/meta.rs +++ b/src/builtin/meta.rs @@ -1,11 +1,11 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use super::{Builtin, GLOBAL_FUNCTIONS}; use crate::common::QuoteKind; use crate::units::Unit; use crate::value::Value; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "if", |args, _| { max_args!(args, 3); if arg!(args, 0, "condition").is_true()? { diff --git a/src/builtin/mod.rs b/src/builtin/mod.rs index eced1c3..cb61dc9 100644 --- a/src/builtin/mod.rs +++ b/src/builtin/mod.rs @@ -1,5 +1,5 @@ use lazy_static::lazy_static; -use std::collections::BTreeMap; +use std::collections::HashMap; use crate::args::CallArgs; use crate::common::Scope; @@ -20,8 +20,8 @@ mod string; pub(crate) type Builtin = Box SassResult + Send + Sync>; lazy_static! { - pub(crate) static ref GLOBAL_FUNCTIONS: BTreeMap = { - let mut m = BTreeMap::new(); + pub(crate) static ref GLOBAL_FUNCTIONS: HashMap = { + let mut m = HashMap::new(); color::register(&mut m); list::register(&mut m); math::register(&mut m); diff --git a/src/builtin/string.rs b/src/builtin/string.rs index a782ae7..17d9364 100644 --- a/src/builtin/string.rs +++ b/src/builtin/string.rs @@ -1,4 +1,4 @@ -use std::collections::BTreeMap; +use std::collections::HashMap; use num_bigint::BigInt; use num_traits::cast::ToPrimitive; @@ -9,7 +9,7 @@ use crate::common::QuoteKind; use crate::units::Unit; use crate::value::{Number, Value}; -pub(crate) fn register(f: &mut BTreeMap) { +pub(crate) fn register(f: &mut HashMap) { decl!(f "to-upper-case", |args, _| { max_args!(args, 1); match arg!(args, 0, "string") {