Skip to content

Commit

Permalink
Update croaring (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinlesceller authored Feb 21, 2020
1 parent 6bca34c commit ef853ae
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 221 deletions.
2 changes: 1 addition & 1 deletion .ci/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ steps:
condition: eq( variables['Agent.OS'], 'Darwin' )
- script: |
sudo apt-get update -yqq
sudo apt-get install -yqq --no-install-recommends libncursesw5-dev
sudo apt-get install -yqq --no-install-recommends libncursesw5-dev libclang-dev clang
displayName: Linux Install Dependencies
condition: eq( variables['Agent.OS'], 'Linux' )
126 changes: 63 additions & 63 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bitflags = "1"
byteorder = "1"
failure = "0.1"
failure_derive = "0.1"
croaring = "0.3.9"
croaring = "0.4"
log = "0.4"
serde = "1"
serde_derive = "1"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
[dependencies]
blake2 = { package = "blake2-rfc", version = "0.2"}
byteorder = "1"
croaring = "0.3.9"
croaring = "0.4"
enum_primitive = "0.1"
failure = "0.1"
failure_derive = "0.1"
Expand Down
279 changes: 132 additions & 147 deletions core/fuzz/Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2018"

[dependencies]
byteorder = "1"
croaring = "0.3.9"
croaring = "0.4"
libc = "0.2"
failure = "0.1"
failure_derive = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions store/src/leaf_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl LeafSet {

// First remove pos from leaf_set that were
// added after the point we are rewinding to.
let to_remove = ((cutoff_pos + 1) as u32)..bitmap.maximum();
let to_remove = ((cutoff_pos + 1) as u32)..bitmap.maximum().unwrap_or(0);
bitmap.remove_range_closed(to_remove);

// Then add back output pos to the leaf_set
Expand All @@ -133,7 +133,7 @@ impl LeafSet {
pub fn rewind(&mut self, cutoff_pos: u64, rewind_rm_pos: &Bitmap) {
// First remove pos from leaf_set that were
// added after the point we are rewinding to.
let to_remove = ((cutoff_pos + 1) as u32)..self.bitmap.maximum();
let to_remove = ((cutoff_pos + 1) as u32)..self.bitmap.maximum().unwrap_or(0);
self.bitmap.remove_range_closed(to_remove);

// Then add back output pos to the leaf_set
Expand Down
11 changes: 6 additions & 5 deletions store/src/prune_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ impl PruneList {
/// Return the total shift from all entries in the prune_list.
/// This is the shift we need to account for when adding new entries to our PMMR.
pub fn get_total_shift(&self) -> u64 {
self.get_shift(self.bitmap.maximum() as u64)
self.get_shift(self.bitmap.maximum().unwrap_or(0) as u64)
}

/// Return the total leaf_shift from all entries in the prune_list.
/// This is the leaf_shift we need to account for when adding new entries to our PMMR.
pub fn get_total_leaf_shift(&self) -> u64 {
self.get_leaf_shift(self.bitmap.maximum() as u64)
self.get_leaf_shift(self.bitmap.maximum().unwrap_or(0) as u64)
}

/// Computes by how many positions a node at pos should be shifted given the
Expand Down Expand Up @@ -276,9 +276,10 @@ impl PruneList {
if self.bitmap.is_empty() {
return;
}
self.pruned_cache = Bitmap::create_with_capacity(self.bitmap.maximum());
for pos in 1..=self.bitmap.maximum() {
let path = path(pos as u64, self.bitmap.maximum() as u64);
let maximum = self.bitmap.maximum().unwrap_or(0);
self.pruned_cache = Bitmap::create_with_capacity(maximum);
for pos in 1..(maximum + 1) {
let path = path(pos as u64, maximum as u64);
let pruned = path.into_iter().any(|x| self.bitmap.contains(x as u32));
if pruned {
self.pruned_cache.add(pos as u32)
Expand Down

0 comments on commit ef853ae

Please sign in to comment.