protocol: fix manually copying, use clone_from_slice, thanks clippy! (manual_memcpy)
This commit is contained in:
parent
72f0595111
commit
783e437397
|
@ -1343,11 +1343,8 @@ impl Write for Conn {
|
||||||
match self.cipher.as_mut() {
|
match self.cipher.as_mut() {
|
||||||
Option::None => self.stream.write(buf),
|
Option::None => self.stream.write(buf),
|
||||||
Option::Some(cipher) => {
|
Option::Some(cipher) => {
|
||||||
// TODO: avoid copying, but trait requires non-mutable buf
|
|
||||||
let mut data = vec![0; buf.len()];
|
let mut data = vec![0; buf.len()];
|
||||||
for i in 0..buf.len() {
|
data[..buf.len()].clone_from_slice(&buf[..]);
|
||||||
data[i] = buf[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
cipher.encrypt(&mut data);
|
cipher.encrypt(&mut data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue