From 90bd0636c49f1c88136871c6d76b0e5702349940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 1 Oct 2020 13:34:04 +0200 Subject: [PATCH] Optimize call result push to the stack --- lib/fizzy/execute.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/fizzy/execute.cpp b/lib/fizzy/execute.cpp index 1992d720d..1650a24e8 100644 --- a/lib/fizzy/execute.cpp +++ b/lib/fizzy/execute.cpp @@ -524,12 +524,10 @@ inline bool invoke_function(const FuncType& func_type, uint32_t func_idx, Instan stack.drop(num_args); - const auto num_outputs = func_type.outputs.size(); - // NOTE: we can assume these two from validation - assert(num_outputs <= 1); - assert(ret.has_value == (num_outputs == 1)); + // NOTE: validation ensures there is at most 1 output value + assert(func_type.outputs.size() == (ret.has_value ? 1 : 0)); // Push back the result - if (num_outputs != 0) + if (ret.has_value) stack.push(ret.value); return true;