Skip to content

Commit

Permalink
Improve serde size
Browse files Browse the repository at this point in the history
  • Loading branch information
Firstyear committed Apr 10, 2021
1 parent 94ec2ec commit 9608a36
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ const FAST_PATH_BST_SIZE: usize = 8;

/// The core representation of sets of integers in compressed format.
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename = "R")]
struct IDLRange {
#[serde(rename = "r")]
pub range: u64,
#[serde(rename = "m")]
pub mask: u64,
}

Expand All @@ -56,8 +59,11 @@ impl PartialEq for IDLRange {
impl Eq for IDLRange {}

#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
#[serde(rename = "S")]
enum IDLState {
#[serde(rename = "s")]
Sparse(SmallVec<[u64; DEFAULT_SPARSE_ALLOC]>),
#[serde(rename = "c")]
Compressed(Vec<IDLRange>),
}

Expand Down Expand Up @@ -106,7 +112,7 @@ impl fmt::Debug for IDLBitRange {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &self.state {
IDLState::Sparse(list) => {
write!(f, "IDLBitRange (sparse values) {:?} (data) [ ", list.len());
write!(f, "IDLBitRange (sparse values) {:?} (data) [ ", list.len())?;
}
IDLState::Compressed(list) => {
write!(f, "IDLBitRange (compressed) {:?} (decompressed) [ ", list)?;
Expand Down Expand Up @@ -141,7 +147,9 @@ impl fmt::Debug for IDLBitRange {
/// assert_eq!(idl_result, idl_expect);
/// ```
#[derive(Serialize, Deserialize, PartialEq, Clone)]
#[serde(rename = "IDLV2")]
pub struct IDLBitRange {
#[serde(rename = "t")]
state: IDLState,
}

Expand Down

0 comments on commit 9608a36

Please sign in to comment.