Use Vec::with_capacity when we know the eventual size of the Vec.

This commit is contained in:
Dan Gohman
2019-01-02 11:59:57 -08:00
parent 29edc3fe50
commit cd4f96c066

View File

@@ -255,7 +255,7 @@ pub fn parse_element_section<'data>(
ref s => panic!("unsupported init expr in element section: {:?}", s),
};
let items_reader = items.get_items_reader()?;
let mut elems = Vec::new();
let mut elems = Vec::with_capacity(cast::usize(items_reader.get_count()));
for item in items_reader {
let x = item?;
elems.push(FuncIndex::from_u32(x));