##// END OF EJS Templates
rhg: in path_encode, make DestArr generic over its size
Arseniy Alekseyev -
r51056:5d7ba99d default
parent child Browse files
Show More
@@ -47,15 +47,15 b' fn inset(bitset: &[u32; 8], c: u8) -> bo'
47 47
48 48 const MAXENCODE: usize = 4096 * 4;
49 49
50 struct DestArr {
51 buf: [u8; MAXENCODE],
50 struct DestArr<const N: usize> {
51 buf: [u8; N],
52 52 pub len: usize,
53 53 }
54 54
55 impl DestArr {
55 impl<const N: usize> DestArr<N> {
56 56 pub fn create() -> Self {
57 57 DestArr {
58 buf: [0; MAXENCODE],
58 buf: [0; N],
59 59 len: 0,
60 60 }
61 61 }
@@ -65,7 +65,7 b' impl DestArr {'
65 65 }
66 66 }
67 67
68 impl Sink for DestArr {
68 impl<const N: usize> Sink for DestArr<N> {
69 69 fn write_byte(&mut self, c: u8) {
70 70 self.buf[self.len] = c;
71 71 self.len += 1;
@@ -600,9 +600,9 b' fn hash_mangle(src: &[u8], sha: &[u8]) -'
600 600 }
601 601
602 602 fn hash_encode(src: &[u8]) -> Vec<u8> {
603 let mut dired = DestArr::create();
604 let mut lowered = DestArr::create();
605 let mut auxed = DestArr::create();
603 let mut dired: DestArr<MAXENCODE> = DestArr::create();
604 let mut lowered: DestArr<MAXENCODE> = DestArr::create();
605 let mut auxed: DestArr<MAXENCODE> = DestArr::create();
606 606 let baselen = (src.len() - 5) * 3;
607 607 if baselen >= MAXENCODE {
608 608 panic!("path_encode::hash_encore: string too long: {}", baselen)
General Comments 0
You need to be logged in to leave comments. Login now