swf: Avoid some `Vec::resize` usages
Use the `vec![]` macro instead.
This commit is contained in:
parent
da613a6fc5
commit
984342abf3
|
@ -318,12 +318,10 @@ impl<'gc> Avm2<'gc> {
|
|||
}
|
||||
|
||||
fn pop_args(&mut self, arg_count: u32) -> Vec<Value<'gc>> {
|
||||
let mut args = Vec::with_capacity(arg_count as usize);
|
||||
args.resize(arg_count as usize, Value::Undefined);
|
||||
let mut args = vec![Value::Undefined; arg_count as usize];
|
||||
for arg in args.iter_mut().rev() {
|
||||
*arg = self.pop();
|
||||
}
|
||||
|
||||
args
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,9 @@ impl<'gc> ArrayStorage<'gc> {
|
|||
/// The length parameter indicates how big the array storage should start
|
||||
/// out as. All array storage consists of holes.
|
||||
pub fn new(length: usize) -> Self {
|
||||
let mut storage = Vec::new();
|
||||
|
||||
storage.resize(length, None);
|
||||
|
||||
Self { storage }
|
||||
Self {
|
||||
storage: vec![None; length],
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a set of arguments into array storage.
|
||||
|
|
|
@ -1011,16 +1011,15 @@ impl<'a> Reader<'a> {
|
|||
let name = self.read_str_with_len(name_len.into())?;
|
||||
|
||||
let num_glyphs = self.read_u16()? as usize;
|
||||
let mut glyphs = Vec::with_capacity(num_glyphs);
|
||||
glyphs.resize(
|
||||
num_glyphs,
|
||||
let mut glyphs = vec![
|
||||
Glyph {
|
||||
shape_records: vec![],
|
||||
code: 0,
|
||||
advance: None,
|
||||
bounds: None,
|
||||
},
|
||||
);
|
||||
};
|
||||
num_glyphs
|
||||
];
|
||||
|
||||
// SWF19 p. 164 doesn't make it super clear: If there are no glyphs,
|
||||
// then the following tables are omitted. But the table offset values
|
||||
|
|
Loading…
Reference in New Issue