mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 21:54:36 +03:00
fix(css/prefixer): Reduce the number of vars in debug build (#4078)
This commit is contained in:
parent
0087627910
commit
4af5e6d77b
@ -1,5 +1,6 @@
|
||||
use std::mem::take;
|
||||
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_css_ast::*;
|
||||
use swc_css_utils::{
|
||||
@ -195,6 +196,41 @@ struct Prefixer {
|
||||
added_declarations: Vec<Declaration>,
|
||||
}
|
||||
|
||||
impl Prefixer {
|
||||
fn simple(&mut self, name: JsWord, val: JsWord, n: &Declaration) {
|
||||
let val = ComponentValue::Ident(Ident {
|
||||
span: DUMMY_SP,
|
||||
value: val.clone(),
|
||||
raw: val,
|
||||
});
|
||||
let name = DeclarationName::Ident(Ident {
|
||||
span: DUMMY_SP,
|
||||
value: name.clone(),
|
||||
raw: name,
|
||||
});
|
||||
self.added_declarations.push(Declaration {
|
||||
span: n.span,
|
||||
name,
|
||||
value: vec![val],
|
||||
important: n.important.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
fn same_name(&mut self, name: JsWord, n: &Declaration) {
|
||||
let val = Ident {
|
||||
span: DUMMY_SP,
|
||||
value: name.clone(),
|
||||
raw: name,
|
||||
};
|
||||
self.added_declarations.push(Declaration {
|
||||
span: n.span,
|
||||
name: n.name.clone(),
|
||||
value: vec![ComponentValue::Ident(val)],
|
||||
important: n.important.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Prefix {
|
||||
Webkit,
|
||||
Moz,
|
||||
@ -438,38 +474,13 @@ impl VisitMut for Prefixer {
|
||||
|
||||
macro_rules! simple {
|
||||
($name:expr,$val:expr) => {{
|
||||
let val = ComponentValue::Ident(Ident {
|
||||
span: DUMMY_SP,
|
||||
value: $val.into(),
|
||||
raw: $val.into(),
|
||||
});
|
||||
let name = DeclarationName::Ident(Ident {
|
||||
span: DUMMY_SP,
|
||||
value: $name.into(),
|
||||
raw: $name.into(),
|
||||
});
|
||||
self.added_declarations.push(Declaration {
|
||||
span: n.span,
|
||||
name,
|
||||
value: vec![val],
|
||||
important: n.important.clone(),
|
||||
});
|
||||
self.simple($name.into(), $val.into(), &n);
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! same_name {
|
||||
($name:expr) => {{
|
||||
let val = Ident {
|
||||
span: DUMMY_SP,
|
||||
value: $name.into(),
|
||||
raw: $name.into(),
|
||||
};
|
||||
self.added_declarations.push(Declaration {
|
||||
span: n.span,
|
||||
name: n.name.clone(),
|
||||
value: vec![ComponentValue::Ident(val)],
|
||||
important: n.important.clone(),
|
||||
});
|
||||
self.same_name($name.into(), &n);
|
||||
}};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user