Use u8/usize directly without references

This commit is contained in:
sharkdp committed 2019-04-13 18:32:59 +02:00
1 parent 3390bedee9
commit a2ea80e960
2 files changed
+11 -11

No files matched your search

+1 -1
View File
@@ -272,7 +272,7 @@ impl<'a> Printer<'a> {
write!(&mut self.buffer_line, "{}", self.byte_hex_table[b as usize])?;
self.raw_line.push(b);
self.squeezer.process(&b, &self.idx);
self.squeezer.process(b, self.idx);
match self.idx % 16 {
8 => {
+10 -10
View File
@@ -46,12 +46,12 @@ impl Squeezer {
}
}
pub fn process(&mut self, b: &u8, i: &usize) {
pub fn process(&mut self, b: u8, i: usize) {
use self::SqueezeState::*;
if self.state == Disabled {
return;
}
let eq = *b == self.byte;
let eq = b == self.byte;
if i % LSIZE == 0 {
self.state = match self.state {
@@ -69,7 +69,7 @@ impl Squeezer {
}
}
self.byte = b.clone();
self.byte = b;
}
pub fn active(&self) -> bool {
@@ -115,7 +115,7 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}
@@ -139,13 +139,13 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}
for i in LSIZE * LINES..LINES * LSIZE + 12 {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[3]);
}
@@ -171,7 +171,7 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}
@@ -197,7 +197,7 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}
@@ -222,7 +222,7 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}
@@ -252,7 +252,7 @@ mod tests {
for z in 0..LINES {
for i in z * LSIZE..(z + 1) * LSIZE {
s.process(&v[i], &(i + 1));
s.process(v[i], i + 1);
}
assert_eq!(s.action(), exp[z]);
}