From ad254790a4f3ff65edbdebfa2608881e9baab817 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Fri, 11 Oct 2019 16:30:01 +0200 Subject: [PATCH] Avoid temporary allocation when push locals during function invocation. --- src/runner.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/runner.rs b/src/runner.rs index bcc1853..2f10954 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -1289,13 +1289,9 @@ impl FunctionContext { debug_assert!(!self.is_initialized); let num_locals = locals.iter().map(|l| l.count() as usize).sum(); - let locals = vec![Default::default(); num_locals]; - // TODO: Replace with extend. - for local in locals { - value_stack - .push(local) - .map_err(|_| TrapKind::StackOverflow)?; + for _ in 0..num_locals { + value_stack.push(Default::default())?; } self.is_initialized = true;