diff --git a/core/src/avm2.rs b/core/src/avm2.rs index 3c27821fc..e3686d7a2 100644 --- a/core/src/avm2.rs +++ b/core/src/avm2.rs @@ -318,12 +318,10 @@ impl<'gc> Avm2<'gc> { } fn pop_args(&mut self, arg_count: u32) -> Vec> { - 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 } diff --git a/core/src/avm2/array.rs b/core/src/avm2/array.rs index e489651e4..64342a15b 100644 --- a/core/src/avm2/array.rs +++ b/core/src/avm2/array.rs @@ -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. diff --git a/swf/src/read.rs b/swf/src/read.rs index cd0104180..4a77b49c2 100644 --- a/swf/src/read.rs +++ b/swf/src/read.rs @@ -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