media-converter: Simplify array copy
This commit is contained in:
parent
a2ccc70f7b
commit
370dc01d07
1 changed files with 5 additions and 19 deletions
|
@ -213,14 +213,7 @@ impl<'a> Read for PadReader<'a> {
|
|||
return Ok(0);
|
||||
}
|
||||
|
||||
if to_copy == out.len() {
|
||||
out.copy_from_slice(&self.chunk[self.chunk_offs..(self.chunk_offs + to_copy)]);
|
||||
}else{
|
||||
/* FIXME: there's probably some cool functional way to do this */
|
||||
for i in 0..to_copy {
|
||||
out[i] = self.chunk[self.chunk_offs + i];
|
||||
}
|
||||
}
|
||||
out[..to_copy].copy_from_slice(&self.chunk[self.chunk_offs..(self.chunk_offs + to_copy)]);
|
||||
|
||||
self.chunk_offs += to_copy;
|
||||
|
||||
|
@ -288,18 +281,11 @@ impl VideoConvState {
|
|||
None => {
|
||||
let blank = include_bytes!("../blank.ogv");
|
||||
|
||||
let remaining = blank.len() - offs;
|
||||
let to_copy = std::cmp::min(blank.len() - offs, out.len());
|
||||
|
||||
if out.len() <= remaining {
|
||||
out.copy_from_slice(&blank[offs..(offs + out.len())]);
|
||||
Ok(out.len())
|
||||
}else{
|
||||
/* FIXME: there's probably some cool functional way to do this */
|
||||
for i in 0..remaining {
|
||||
out[i] = blank[offs + i];
|
||||
}
|
||||
Ok(remaining)
|
||||
}
|
||||
out[..to_copy].copy_from_slice(&blank[offs..(offs + to_copy)]);
|
||||
|
||||
Ok(to_copy)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue