Use drain() instead of reallocating.

This commit is contained in:
Todd Mortimer 2021-04-05 16:10:32 -04:00
parent e1db863691
commit 064c2e08dc

View file

@ -177,7 +177,8 @@ impl<'a, T: Read + Write + 'a> Handle<'a, T> {
if rest.is_empty() { if rest.is_empty() {
v.clear(); v.clear();
} else if rest.len() != v.len() { } else if rest.len() != v.len() {
v = rest.into(); let used = v.len() - rest.len();
v.drain(0..used);
} }
}; };