std.BoundedArray: popOrNull() -> pop() [v2] (#22723)

This commit is contained in:
Meghan Denny
2025-02-09 03:46:15 -08:00
committed by GitHub
parent 4e4775d6bd
commit 933ba935c5
2 changed files with 12 additions and 18 deletions

View File

@@ -15,18 +15,18 @@ fn evaluate(initial_stack: []const i32, code: []const Instruction) !i32 {
// Because all code after `continue` is unreachable, this branch does
// not provide a result.
.add => {
try stack.append(stack.pop() + stack.pop());
try stack.append(stack.pop().? + stack.pop().?);
ip += 1;
continue :vm code[ip];
},
.mul => {
try stack.append(stack.pop() * stack.pop());
try stack.append(stack.pop().? * stack.pop().?);
ip += 1;
continue :vm code[ip];
},
.end => stack.pop(),
.end => stack.pop().?,
};
}