Skip to content

Commit 9e99e01

Browse files
committed
Turn git-bitmap Array into Vec, as it will be able to adjust its size (#293)
1 parent 3f89b63 commit 9e99e01

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

git-bitmap/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub mod ewah {
3232
}
3333
}
3434

35-
pub fn decode(data: &[u8]) -> Result<(Array, &[u8]), decode::Error> {
35+
pub fn decode(data: &[u8]) -> Result<(Vec, &[u8]), decode::Error> {
3636
let (num_bits, data) = decode::u32(data).ok_or(decode::Error::Corrupt("eof reading amount of bits"))?;
3737
let (len, data) = decode::u32(data).ok_or(decode::Error::Corrupt("eof reading chunk length"))?;
3838
let len = len as usize;
@@ -42,7 +42,7 @@ pub mod ewah {
4242
// one day somebody will find out that it's worth it to use unsafe here.
4343
let (mut bits, data) = decode::split_at_pos(data, len * std::mem::size_of::<u64>())
4444
.ok_or(decode::Error::Corrupt("eof while reading bit data"))?;
45-
let mut buf = Vec::<u64>::with_capacity(len);
45+
let mut buf = std::vec::Vec::<u64>::with_capacity(len);
4646
for _ in 0..len {
4747
let (bit_num, rest) = bits.split_at(std::mem::size_of::<u64>());
4848
bits = rest;
@@ -52,7 +52,7 @@ pub mod ewah {
5252
let (rlw, data) = decode::u32(data).ok_or(decode::Error::Corrupt("eof while reading run length width"))?;
5353

5454
Ok((
55-
Array {
55+
Vec {
5656
num_bits,
5757
bits: buf,
5858
rlw,
@@ -61,10 +61,11 @@ pub mod ewah {
6161
))
6262
}
6363

64+
/// A growable collection of u64 that are seen as stream of individual bits.
6465
#[allow(dead_code)]
65-
pub struct Array {
66+
pub struct Vec {
6667
num_bits: u32,
67-
bits: Vec<u64>,
68+
bits: std::vec::Vec<u64>,
6869
rlw: u32,
6970
}
7071
}

git-index/src/extension/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub mod link {
4242
pub const SIGNATURE: Signature = *b"link";
4343

4444
pub struct Bitmaps {
45-
pub delete: git_bitmap::ewah::Array,
46-
pub replace: git_bitmap::ewah::Array,
45+
pub delete: git_bitmap::ewah::Vec,
46+
pub replace: git_bitmap::ewah::Vec,
4747
}
4848

4949
pub mod decode {

0 commit comments

Comments
 (0)