History

Put crc functionality behind a feature toggle

Sebastian Thiel committed 5 years ago

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

Unified · Split

4 files
  1. cargo-features.md +2 −0
  2. git-features/Cargo.toml +2 −1
  3. git-features/src/hash.rs +2 −0
  4. git-odb/Cargo.toml +1 −1
cargo-features.md+2−0
@@ -77,6 +77,8 @@ All feature toggles are additive. · 76 unmodified lines
7777 * **fast-sha1**
7878 * a multi-crate implementation that can use hardware acceleration, thus bearing the potential for up to 2Gb/s throughput on
7979 CPUs that support it, like AMD Ryzen or Intel Core i3.
80+* **crc32**
81+ * provide a proven `crc32` implementation.
8082 * _mutually-exclusive_
8183 * **interrupt-handler**
8284 * Listen to interrupts and termination requests and provide long-running operations tooling to allow aborting the input stream.
git-features/Cargo.toml+2−1
@@ -17,6 +17,7 @@ fast-sha1 = ["fastsha1"] · 16 unmodified lines
1717 interrupt-handler = ["ctrlc"]
1818 disable-interrupts = []
1919 io-pipe = ["bytes"]
20+crc32 = ["crc"]
2021
2122 [[test]]
2223 name = "parallel"
@@ -51,7 +52,7 @@ walkdir = { version = "2.3.1" } # used when parallel is off · 28 unmodified lines
5152
5253 # hashing and 'fast-sha1' feature
5354 sha1 = "0.6.0"
54−crc = "1.8.1"
55+crc = { version = "1.8.1", optional = true }
5556 fastsha1 = { package = "sha-1", version = "0.9.1", optional = true }
5657
5758 # progress
git-features/src/hash.rs+2−0
@@ -55,6 +55,7 @@ pub use _impl::Sha1; · 54 unmodified lines
5555 /// When calling this function for the first time, `previous_value` should be `0`. Otherwise it
5656 /// should be the previous return value of this function to provide a hash of multiple sequential
5757 /// chunks of `bytes`.
58+#[cfg(feature = "crc32")]
5859 pub fn crc32_update(previous_value: u32, bytes: &[u8]) -> u32 {
5960 crc::crc32::update(previous_value, &crc::crc32::IEEE_TABLE, bytes)
6061 }
@@ -62,6 +63,7 @@ pub fn crc32_update(previous_value: u32, bytes: &[u8]) -> u32 { · 1 unmodified line
6263 /// Compute a CRC32 value of the given input `bytes`.
6364 ///
6465 /// In case multiple chunkes of `bytes` are present, one should use [`crc32_update()`] instead.
66+#[cfg(feature = "crc32")]
6567 pub use crc::crc32::checksum_ieee as crc32;
6668
6769 /// Compute the hash of `kind` for the bytes in the file at `path`, hashing only the first `num_bytes_from_start`
git-odb/Cargo.toml+1−1
@@ -32,7 +32,7 @@ required-features = [] · 31 unmodified lines
3232 all-features = true
3333
3434 [dependencies]
35−git-features = { version = "^0.14.0", path = "../git-features" }
35+git-features = { version = "^0.14.0", path = "../git-features", features = ["crc32"] }
3636 git-hash = { version = "^0.3.0", path = "../git-hash" }
3737 git-object = { version = "^0.10.0", path = "../git-object" }
3838 git-traverse = { version = "^0.3", path = "../git-traverse" }