History

Put crc functionality behind a feature toggle

Sebastian Thiel committed 5 years ago

Commit 458fa6e1 parent b6b58564 files · +7 −2Browse files

Showing the changes to git-features (2 of 4 files). Show all

Unified · Split

2 files
  1. git-features/Cargo.toml +2 −1
  2. git-features/src/hash.rs +2 −0
git-features/Cargo.toml+2−1
@@ -17,6 +17,7 @@ fast-sha1 = ["fastsha1"] · 16 unmodified lines
17interrupt-handler = ["ctrlc"]17interrupt-handler = ["ctrlc"]
18disable-interrupts = []18disable-interrupts = []
19io-pipe = ["bytes"]19io-pipe = ["bytes"]
20crc32 = ["crc"]
20 21
21[[test]]22[[test]]
22name = "parallel"23name = "parallel"
@@ -51,7 +52,7 @@ walkdir = { version = "2.3.1" } # used when parallel is off · 28 unmodified lines
51 52
52# hashing and 'fast-sha1' feature53# hashing and 'fast-sha1' feature
53sha1 = "0.6.0"54sha1 = "0.6.0"
54crc = "1.8.1"55crc = { version = "1.8.1", optional = true }
55fastsha1 = { package = "sha-1", version = "0.9.1", optional = true }56fastsha1 = { package = "sha-1", version = "0.9.1", optional = true }
56 57
57# progress58# progress
git-features/src/hash.rs+2−0
@@ -55,6 +55,7 @@ pub use _impl::Sha1; · 54 unmodified lines
55/// When calling this function for the first time, `previous_value` should be `0`. Otherwise it55/// When calling this function for the first time, `previous_value` should be `0`. Otherwise it
56/// should be the previous return value of this function to provide a hash of multiple sequential56/// should be the previous return value of this function to provide a hash of multiple sequential
57/// chunks of `bytes`.57/// chunks of `bytes`.
58#[cfg(feature = "crc32")]
58pub fn crc32_update(previous_value: u32, bytes: &[u8]) -> u32 {59pub fn crc32_update(previous_value: u32, bytes: &[u8]) -> u32 {
59 crc::crc32::update(previous_value, &crc::crc32::IEEE_TABLE, bytes)60 crc::crc32::update(previous_value, &crc::crc32::IEEE_TABLE, bytes)
60}61}
@@ -62,6 +63,7 @@ pub fn crc32_update(previous_value: u32, bytes: &[u8]) -> u32 { · 1 unmodified line
62/// Compute a CRC32 value of the given input `bytes`.63/// Compute a CRC32 value of the given input `bytes`.
63///64///
64/// In case multiple chunkes of `bytes` are present, one should use [`crc32_update()`] instead.65/// In case multiple chunkes of `bytes` are present, one should use [`crc32_update()`] instead.
66#[cfg(feature = "crc32")]
65pub use crc::crc32::checksum_ieee as crc32;67pub use crc::crc32::checksum_ieee as crc32;
66 68
67/// Compute the hash of `kind` for the bytes in the file at `path`, hashing only the first `num_bytes_from_start`69/// Compute the hash of `kind` for the bytes in the file at `path`, hashing only the first `num_bytes_from_start`