# HG changeset patch # User Arseniy Alekseyev # Date 1676573123 0 # Node ID 5d7ba99da3b875d256c447800cd9fc188917541b # Parent 5ce53ff6133a9f7fea3e2bd3d9368c35a19c7350 rhg: in path_encode, make DestArr generic over its size diff -r 5ce53ff6133a -r 5d7ba99da3b8 rust/hg-core/src/revlog/path_encode.rs --- a/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 18:41:06 2023 +0000 +++ b/rust/hg-core/src/revlog/path_encode.rs Thu Feb 16 18:45:23 2023 +0000 @@ -47,15 +47,15 @@ const MAXENCODE: usize = 4096 * 4; -struct DestArr { - buf: [u8; MAXENCODE], +struct DestArr { + buf: [u8; N], pub len: usize, } -impl DestArr { +impl DestArr { pub fn create() -> Self { DestArr { - buf: [0; MAXENCODE], + buf: [0; N], len: 0, } } @@ -65,7 +65,7 @@ } } -impl Sink for DestArr { +impl Sink for DestArr { fn write_byte(&mut self, c: u8) { self.buf[self.len] = c; self.len += 1; @@ -600,9 +600,9 @@ } fn hash_encode(src: &[u8]) -> Vec { - let mut dired = DestArr::create(); - let mut lowered = DestArr::create(); - let mut auxed = DestArr::create(); + let mut dired: DestArr = DestArr::create(); + let mut lowered: DestArr = DestArr::create(); + let mut auxed: DestArr = DestArr::create(); let baselen = (src.len() - 5) * 3; if baselen >= MAXENCODE { panic!("path_encode::hash_encore: string too long: {}", baselen)