Skip to content

Commit

Permalink
Migrate off of bitvec-old
Browse files Browse the repository at this point in the history
Summary: Remove an existing instance of duplicate crate imports

Reviewed By: jasonwhite

Differential Revision: D57676132

fbshipit-source-id: 4a3861c3b79f19c77bc3b4c0f43087a9e58970c2
  • Loading branch information
capickett authored and facebook-github-bot committed May 22, 2024
1 parent 5ebb3fa commit 25d8632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion detcore-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "BSD-3-Clause"

[dependencies]
anyhow = "1.0.75"
bitvec = { version = "0.17", features = ["serde"] }
bitvec = { version = "1.0", features = ["serde"] }
bytesize = "1.1"
chrono = { version = "0.4", features = ["clock", "serde", "std"], default-features = false }
clap = { version = "3.2.25", features = ["derive", "env", "regex", "unicode", "wrap_help"] }
Expand Down
16 changes: 7 additions & 9 deletions detcore-model/src/pedigree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use std::fmt;
use std::io;
use std::mem;

use bitvec::bitvec;
use bitvec::order::Msb0;
use bitvec::vec::BitVec;
use bitvec::prelude::*;
use libc::pid_t;
use nix::unistd::Pid;
use serde::Deserialize;
Expand Down Expand Up @@ -118,7 +116,7 @@ impl TryFrom<&Pedigree> for i32 {
// Trim off any trailing P's from pedigree, i.e. viewing it as
// a sequence of 'P' (parent) and 'C' (child) directions.
let mut sequence = pedigree.raw();
while sequence.len() > 1 && sequence.last() == Some(&false) {
while sequence.len() > 1 && sequence.last().as_deref() == Some(&false) {
sequence.pop();
}

Expand All @@ -142,7 +140,7 @@ impl TryFrom<&Pedigree> for i32 {
tree.append(&mut lower_tree);

// Construct a BitVec which will be interpreted as a pid_t
let mut vpid_bits: BitVec<Msb0, u32> =
let mut vpid_bits: BitVec<u32, Msb0> =
BitVec::with_capacity(mem::size_of::<pid_t>() * 8);

// pid_t is signed, so MSB must always be zero or it will be interpreted as error
Expand All @@ -152,22 +150,22 @@ impl TryFrom<&Pedigree> for i32 {
// Pack the rest of the bits, using asserts to make sure the bitfield sizing
// is correct. Any errors here are fatal bugs, so assert seems acceptable.

let mut tree_bits: BitVec<Msb0, u32> = BitVec::repeat(false, TREE_BITS - tree.len());
let mut tree_bits: BitVec<u32, Msb0> = BitVec::repeat(false, TREE_BITS - tree.len());
tree_bits.append(&mut tree);
debug_assert!(tree_bits.len() == TREE_BITS);
vpid_bits.append(&mut tree_bits);

let mut run_index_bits = BitVec::<Msb0, u32>::from_element(index as u32);
let mut run_index_bits = BitVec::<u32, Msb0>::from_element(index as u32);
run_index_bits = run_index_bits.split_off(run_index_bits.len() - RUN_INDEX_BITS);
debug_assert!(run_index_bits.len() == RUN_INDEX_BITS);
vpid_bits.append(&mut run_index_bits);

let mut run_type_bits: BitVec<Msb0, u32> = BitVec::new();
let mut run_type_bits: BitVec<u32, Msb0> = BitVec::new();
run_type_bits.push(run[0]);
debug_assert!(run_type_bits.len() == RUN_TYPE_BITS);
vpid_bits.append(&mut run_type_bits);

let mut run_length_bits = BitVec::<Msb0, u32>::from_element(len as u32);
let mut run_length_bits = BitVec::<u32, Msb0>::from_element(len as u32);
run_length_bits = run_length_bits.split_off(run_length_bits.len() - RUN_LENGTH_BITS);
debug_assert!(run_length_bits.len() == RUN_LENGTH_BITS);
vpid_bits.append(&mut run_length_bits);
Expand Down

0 comments on commit 25d8632

Please sign in to comment.