Skip to content

Commit 0d80021

Browse files
authored
Implement MallocSizeOf for cssparser types (#399)
* Implement MallocSizeOf for cssparser types * Fix clippy lints Signed-off-by: Nico Burns <[email protected]> --------- Signed-off-by: Nico Burns <[email protected]>
1 parent 5e477ab commit 0d80021

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
features:
2323
-
2424
- --features dummy_match_byte
25+
- --features malloc_size_of
2526
include:
2627
- toolchain: nightly
2728
features: --features bench

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cssparser"
3-
version = "0.34.0"
3+
version = "0.34.1"
44
authors = ["Simon Sapin <[email protected]>"]
55

66
description = "Rust implementation of CSS Syntax Level 3"
@@ -25,6 +25,7 @@ dtoa-short = "0.3"
2525
itoa = "1.0"
2626
phf = { version = "0.11.2", features = ["macros"] }
2727
serde = { version = "1.0", features = ["derive"], optional = true }
28+
malloc_size_of = { version = "0.1", default-features = false, optional = true }
2829
smallvec = "1.0"
2930

3031
[profile.profiling]

src/serializer.rs

+3
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ pub enum TokenSerializationType {
466466
Other,
467467
}
468468

469+
#[cfg(feature = "malloc_size_of")]
470+
malloc_size_of::malloc_size_of_is_0!(TokenSerializationType);
471+
469472
impl TokenSerializationType {
470473
/// Return a value that represents the absence of a token, e.g. before the start of the input.
471474
#[deprecated(

src/tokenizer.rs

+6
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ impl<'a> Tokenizer<'a> {
533533
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
534534
pub struct SourcePosition(pub(crate) usize);
535535

536+
#[cfg(feature = "malloc_size_of")]
537+
malloc_size_of::malloc_size_of_is_0!(SourcePosition);
538+
536539
impl SourcePosition {
537540
/// Returns the current byte index in the original input.
538541
#[inline]
@@ -552,6 +555,9 @@ pub struct SourceLocation {
552555
pub column: u32,
553556
}
554557

558+
#[cfg(feature = "malloc_size_of")]
559+
malloc_size_of::malloc_size_of_is_0!(SourceLocation);
560+
555561
fn next_token<'a>(tokenizer: &mut Tokenizer<'a>) -> Result<Token<'a>, ()> {
556562
if tokenizer.is_eof() {
557563
return Err(());

0 commit comments

Comments
 (0)