From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- vendor/adler/src/algo.rs | 146 ----------------------------------------------- 1 file changed, 146 deletions(-) delete mode 100644 vendor/adler/src/algo.rs (limited to 'vendor/adler/src/algo.rs') diff --git a/vendor/adler/src/algo.rs b/vendor/adler/src/algo.rs deleted file mode 100644 index 650cffa..0000000 --- a/vendor/adler/src/algo.rs +++ /dev/null @@ -1,146 +0,0 @@ -use crate::Adler32; -use std::ops::{AddAssign, MulAssign, RemAssign}; - -impl Adler32 { - pub(crate) fn compute(&mut self, bytes: &[u8]) { - // The basic algorithm is, for every byte: - // a = (a + byte) % MOD - // b = (b + a) % MOD - // where MOD = 65521. - // - // For efficiency, we can defer the `% MOD` operations as long as neither a nor b overflows: - // - Between calls to `write`, we ensure that a and b are always in range 0..MOD. - // - We use 32-bit arithmetic in this function. - // - Therefore, a and b must not increase by more than 2^32-MOD without performing a `% MOD` - // operation. - // - // According to Wikipedia, b is calculated as follows for non-incremental checksumming: - // b = n×D1 + (n−1)×D2 + (n−2)×D3 + ... + Dn + n*1 (mod 65521) - // Where n is the number of bytes and Di is the i-th Byte. We need to change this to account - // for the previous values of a and b, as well as treat every input Byte as being 255: - // b_inc = n×255 + (n-1)×255 + ... + 255 + n*65520 - // Or in other words: - // b_inc = n*65520 + n(n+1)/2*255 - // The max chunk size is thus the largest value of n so that b_inc <= 2^32-65521. - // 2^32-65521 = n*65520 + n(n+1)/2*255 - // Plugging this into an equation solver since I can't math gives n = 5552.18..., so 5552. - // - // On top of the optimization outlined above, the algorithm can also be parallelized with a - // bit more work: - // - // Note that b is a linear combination of a vector of input bytes (D1, ..., Dn). - // - // If we fix some value k Self { - U32X4([ - u32::from(bytes[0]), - u32::from(bytes[1]), - u32::from(bytes[2]), - u32::from(bytes[3]), - ]) - } -} - -impl AddAssign for U32X4 { - fn add_assign(&mut self, other: Self) { - for (s, o) in self.0.iter_mut().zip(other.0.iter()) { - *s += o; - } - } -} - -impl RemAssign for U32X4 { - fn rem_assign(&mut self, quotient: u32) { - for s in self.0.iter_mut() { - *s %= quotient; - } - } -} - -impl MulAssign for U32X4 { - fn mul_assign(&mut self, rhs: u32) { - for s in self.0.iter_mut() { - *s *= rhs; - } - } -} -- cgit v1.2.3