prefer hashmap over btreemap where ordering is unimportant
This commit is contained in:
parent
94a6109a05
commit
276134eb93
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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") {
|
||||
|
@ -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());
|
||||
|
@ -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") {
|
||||
|
@ -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()),
|
||||
|
@ -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") {
|
||||
|
@ -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()? {
|
||||
|
@ -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);
|
||||
|
@ -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") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user