prefer hashmap over btreemap where ordering is unimportant

This commit is contained in:
ConnorSkees 2020-03-03 19:51:02 -05:00
parent 94a6109a05
commit 276134eb93
10 changed files with 21 additions and 21 deletions

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "hsl", |args, _| {
let hue = match arg!(args, 0, "hue") {
Value::Dimension(n, _) => n,

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
hsl::register(f);
opacity::register(f);
other::register(f);

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "alpha", |args, _| {
max_args!(args, 1);
match arg!(args, 0, "color") {

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
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());

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "rgb", |args, _| {
if args.len() == 1 {
let mut channels = match arg!(args, 0, "channels") {

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "length", |args, _| {
let len = match arg!(args, 0, "list") {
Value::List(v, _) => Number::from(v.len()),

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "percentage", |args, _| {
max_args!(args, 1);
let num = match arg!(args, 0, "number") {

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "if", |args, _| {
max_args!(args, 3);
if arg!(args, 0, "condition").is_true()? {

View File

@ -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<dyn Fn(&mut CallArgs, &Scope) -> SassResult<Value> + Send + Sync>;
lazy_static! {
pub(crate) static ref GLOBAL_FUNCTIONS: BTreeMap<String, Builtin> = {
let mut m = BTreeMap::new();
pub(crate) static ref GLOBAL_FUNCTIONS: HashMap<String, Builtin> = {
let mut m = HashMap::new();
color::register(&mut m);
list::register(&mut m);
math::register(&mut m);

View File

@ -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<String, Builtin>) {
pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
decl!(f "to-upper-case", |args, _| {
max_args!(args, 1);
match arg!(args, 0, "string") {