Skip to content

Commit dcb79c3

Browse files
committed
Reduce binary size and improve performance
1 parent db4ea84 commit dcb79c3

File tree

5 files changed

+256
-259
lines changed

5 files changed

+256
-259
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ required-features = ["cli"]
6464

6565
[profile.release]
6666
lto = true
67+
codegen-units = 1
68+
panic = 'abort'

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ css-minimizer-webpack-plugin has builtin support for `@parcel/css`. Install `@pa
155155

156156
```
157157
$ node bench.js bootstrap-4.css
158-
cssnano: 542.879ms
158+
cssnano: 544.809ms
159159
159636 bytes
160160
161-
esbuild: 16.839ms
161+
esbuild: 17.199ms
162162
160332 bytes
163163
164-
parcel-css: 4.345ms
165-
143121 bytes
164+
parcel-css: 4.16ms
165+
143091 bytes
166166
167167
168168
$ node bench.js animate.css

src/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ impl<'a, 'b, 'i> QualifiedRuleParser<'i> for StyleRuleParser<'a, 'i> {
711711
}
712712
}
713713

714-
fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
714+
#[inline]
715+
pub fn starts_with_ignore_ascii_case(string: &str, prefix: &str) -> bool {
715716
string.len() >= prefix.len() && string.as_bytes()[0..prefix.len()].eq_ignore_ascii_case(prefix.as_bytes())
716717
}

src/properties/custom.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ fn try_parse_color_token<'i, 't>(f: &CowArcStr<'i>, state: &ParserState, input:
211211

212212
impl<'i> ToCss for TokenList<'i> {
213213
fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError> where W: std::fmt::Write {
214+
if !dest.minify && self.0.len() == 1 && matches!(self.0.first(), Some(token) if token.is_whitespace()) {
215+
return Ok(())
216+
}
217+
214218
for (i, token_or_value) in self.0.iter().enumerate() {
215219
match token_or_value {
216220
TokenOrValue::Color(color) => color.to_css(dest)?,

0 commit comments

Comments
 (0)