projects
/
nihav-player.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
replace vec.truncate(0) with vec.clear()
[nihav-player.git]
/
sndplay
/
src
/
main.rs
diff --git
a/sndplay/src/main.rs
b/sndplay/src/main.rs
index 39ee76dee8edfd164ec99079d929e6a7d71dc301..618c2271b14c9950d8d6429a93ce0d542baf0ec6 100644
(file)
--- a/
sndplay/src/main.rs
+++ b/
sndplay/src/main.rs
@@
-107,7
+107,7
@@
struct Decoder<'a> {
fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: bool, volume: u8) {
if !mute {
fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: bool, volume: u8) {
if !mute {
- tmp.
truncate(0
);
+ tmp.
clear(
);
tmp.reserve(src.len());
let vol = i32::from(volume);
for &sample in src.iter() {
tmp.reserve(src.len());
let vol = i32::from(volume);
for &sample in src.iter() {
@@
-115,7
+115,7
@@
fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: b
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
- tmp.
truncate(0
);
+ tmp.
clear(
);
tmp.resize(src.len(), 0);
}
device.queue(&tmp);
tmp.resize(src.len(), 0);
}
device.queue(&tmp);
@@
-123,7
+123,7
@@
fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[i16], mute: b
fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[u8], mute: bool, volume: u8) {
if !mute {
fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[u8], mute: bool, volume: u8) {
if !mute {
- tmp.
truncate(0
);
+ tmp.
clear(
);
tmp.reserve(src.len());
let vol = i32::from(volume);
for sample in src.chunks_exact(2) {
tmp.reserve(src.len());
let vol = i32::from(volume);
for sample in src.chunks_exact(2) {
@@
-132,7
+132,7
@@
fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec<i16>, src: &[u8], mute: boo
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
tmp.push(nsamp.min(32767).max(-32768) as i16);
}
} else {
- tmp.
truncate(0
);
+ tmp.
clear(
);
tmp.resize(src.len() / 2, 0);
}
device.queue(&tmp);
tmp.resize(src.len() / 2, 0);
}
device.queue(&tmp);