mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-28 16:11:32 +00:00
feat(interface-types) Create vectors with specific capacity when possible.
This commit is contained in:
@ -100,7 +100,7 @@ fn list<'input, I, E: ParseError<&'input [u8]>>(
|
|||||||
return Err(Err::Error(make_error(input, ErrorKind::Eof)));
|
return Err(Err::Error(make_error(input, ErrorKind::Eof)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut items = vec![];
|
let mut items = Vec::with_capacity(length as usize);
|
||||||
|
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
consume!((input, item) = item_parser(input)?);
|
consume!((input, item) = item_parser(input)?);
|
||||||
@ -247,10 +247,11 @@ fn exports<'input, E: ParseError<&'input [u8]>>(
|
|||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
) -> IResult<&'input [u8], Vec<Export>, E> {
|
) -> IResult<&'input [u8], Vec<Export>, E> {
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
let mut exports = vec![];
|
|
||||||
|
|
||||||
consume!((input, number_of_exports) = leb(input)?);
|
consume!((input, number_of_exports) = leb(input)?);
|
||||||
|
|
||||||
|
let mut exports = Vec::with_capacity(number_of_exports as usize);
|
||||||
|
|
||||||
for _ in 0..number_of_exports {
|
for _ in 0..number_of_exports {
|
||||||
consume!((input, export_name) = string(input)?);
|
consume!((input, export_name) = string(input)?);
|
||||||
consume!((input, export_input_types) = list(input, ty)?);
|
consume!((input, export_input_types) = list(input, ty)?);
|
||||||
@ -270,10 +271,11 @@ fn types<'input, E: ParseError<&'input [u8]>>(
|
|||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
) -> IResult<&'input [u8], Vec<Type>, E> {
|
) -> IResult<&'input [u8], Vec<Type>, E> {
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
let mut types = vec![];
|
|
||||||
|
|
||||||
consume!((input, number_of_types) = leb(input)?);
|
consume!((input, number_of_types) = leb(input)?);
|
||||||
|
|
||||||
|
let mut types = Vec::with_capacity(number_of_types as usize);
|
||||||
|
|
||||||
for _ in 0..number_of_types {
|
for _ in 0..number_of_types {
|
||||||
consume!((input, type_name) = string(input)?);
|
consume!((input, type_name) = string(input)?);
|
||||||
consume!((input, type_fields) = list(input, string)?);
|
consume!((input, type_fields) = list(input, string)?);
|
||||||
@ -293,10 +295,11 @@ fn imported_functions<'input, E: ParseError<&'input [u8]>>(
|
|||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
) -> IResult<&'input [u8], Vec<ImportedFunction>, E> {
|
) -> IResult<&'input [u8], Vec<ImportedFunction>, E> {
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
let mut imported_functions = vec![];
|
|
||||||
|
|
||||||
consume!((input, number_of_imported_functions) = leb(input)?);
|
consume!((input, number_of_imported_functions) = leb(input)?);
|
||||||
|
|
||||||
|
let mut imported_functions = Vec::with_capacity(number_of_imported_functions as usize);
|
||||||
|
|
||||||
for _ in 0..number_of_imported_functions {
|
for _ in 0..number_of_imported_functions {
|
||||||
consume!((input, imported_function_namespace) = string(input)?);
|
consume!((input, imported_function_namespace) = string(input)?);
|
||||||
consume!((input, imported_function_name) = string(input)?);
|
consume!((input, imported_function_name) = string(input)?);
|
||||||
@ -318,10 +321,11 @@ fn adapters<'input, E: ParseError<&'input [u8]>>(
|
|||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
) -> IResult<&'input [u8], Vec<Adapter>, E> {
|
) -> IResult<&'input [u8], Vec<Adapter>, E> {
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
let mut adapters = vec![];
|
|
||||||
|
|
||||||
consume!((input, number_of_adapters) = leb(input)?);
|
consume!((input, number_of_adapters) = leb(input)?);
|
||||||
|
|
||||||
|
let mut adapters = Vec::with_capacity(number_of_adapters as usize);
|
||||||
|
|
||||||
for _ in 0..number_of_adapters {
|
for _ in 0..number_of_adapters {
|
||||||
consume!((input, adapter_kind) = byte(input)?);
|
consume!((input, adapter_kind) = byte(input)?);
|
||||||
let adapter_kind = AdapterKind::try_from(adapter_kind)
|
let adapter_kind = AdapterKind::try_from(adapter_kind)
|
||||||
@ -381,10 +385,11 @@ fn forwards<'input, E: ParseError<&'input [u8]>>(
|
|||||||
input: &'input [u8],
|
input: &'input [u8],
|
||||||
) -> IResult<&'input [u8], Vec<Forward>, E> {
|
) -> IResult<&'input [u8], Vec<Forward>, E> {
|
||||||
let mut input = input;
|
let mut input = input;
|
||||||
let mut forwards = vec![];
|
|
||||||
|
|
||||||
consume!((input, number_of_forwards) = leb(input)?);
|
consume!((input, number_of_forwards) = leb(input)?);
|
||||||
|
|
||||||
|
let mut forwards = Vec::with_capacity(number_of_forwards as usize);
|
||||||
|
|
||||||
for _ in 0..number_of_forwards {
|
for _ in 0..number_of_forwards {
|
||||||
consume!((input, forward_name) = string(input)?);
|
consume!((input, forward_name) = string(input)?);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user