mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-02-04 17:50:42 +03:00
media-converter: Simplify array copy
This commit is contained in:
parent
a2ccc70f7b
commit
370dc01d07
@ -213,14 +213,7 @@ impl<'a> Read for PadReader<'a> {
|
|||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if to_copy == out.len() {
|
out[..to_copy].copy_from_slice(&self.chunk[self.chunk_offs..(self.chunk_offs + to_copy)]);
|
||||||
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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.chunk_offs += to_copy;
|
self.chunk_offs += to_copy;
|
||||||
|
|
||||||
@ -288,18 +281,11 @@ impl VideoConvState {
|
|||||||
None => {
|
None => {
|
||||||
let blank = include_bytes!("../blank.ogv");
|
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[..to_copy].copy_from_slice(&blank[offs..(offs + to_copy)]);
|
||||||
out.copy_from_slice(&blank[offs..(offs + out.len())]);
|
|
||||||
Ok(out.len())
|
Ok(to_copy)
|
||||||
}else{
|
|
||||||
/* FIXME: there's probably some cool functional way to do this */
|
|
||||||
for i in 0..remaining {
|
|
||||||
out[i] = blank[offs + i];
|
|
||||||
}
|
|
||||||
Ok(remaining)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user