3% speedup in chat run by allocating vector up front

This commit is contained in:
Midas Lambrichts 2020-08-08 13:36:14 +02:00
parent 66d0d9f62d
commit db904b623b

View File

@ -10,7 +10,7 @@ pub async fn do_resolve<'a, T: ObjectType + Send + Sync>(
ctx: &'a ContextSelectionSet<'a>,
root: &'a T,
) -> Result<serde_json::Value> {
let mut futures = Vec::new();
let mut futures = Vec::with_capacity(ctx.item.items.len());
collect_fields(ctx, root, &mut futures)?;
let res = futures::future::try_join_all(futures).await?;
let mut map = serde_json::Map::new();