From 0247f7d5b7792bc8c08ea36c7510db58557b623e Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Thu, 24 Aug 2023 19:41:05 +0700 Subject: [PATCH 1/2] Move is_bit_set into match body --- src/traverse_path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/traverse_path.rs b/src/traverse_path.rs index 592a7774..30a3c362 100644 --- a/src/traverse_path.rs +++ b/src/traverse_path.rs @@ -52,12 +52,12 @@ pub fn traverse_path(allocator: &Allocator, node_index: &[u8], args: NodePtr) -> let mut byte_idx = node_index.len() - 1; let mut bitmask = 0x01; while byte_idx > first_bit_byte_index || bitmask < last_bitmask { - let is_bit_set: bool = (node_index[byte_idx] & bitmask) != 0; match allocator.sexp(arg_list) { SExp::Atom => { return Err(EvalErr(arg_list, "path into atom".into())); } SExp::Pair(left, right) => { + let is_bit_set = (node_index[byte_idx] & bitmask) != 0; arg_list = if is_bit_set { right } else { left }; } } From cff826b8f3b6d6f9333f969b4e713803af9a36f9 Mon Sep 17 00:00:00 2001 From: Ardika Rommy Sanjaya Date: Fri, 1 Sep 2023 00:00:50 +0700 Subject: [PATCH 2/2] simplify pop operation from op_stack --- src/run_program.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/run_program.rs b/src/run_program.rs index 1c9ad831..ef8235bf 100644 --- a/src/run_program.rs +++ b/src/run_program.rs @@ -475,8 +475,7 @@ impl<'a, D: Dialect> RunProgramContext<'a, D> { if cost > effective_max_cost { return err(max_cost_ptr, "cost exceeded"); } - let top = self.op_stack.pop(); - let op = match top { + let op = match self.op_stack.pop() { Some(f) => f, None => break, };