summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2024-10-07 19:48:12 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2024-10-28 20:02:07 +1300
commitb0d04c9b28efc90bc6f1cfcc6d2c4d3e646099fb (patch)
tree82ab63e43bc696a32be474451d2e6a64fa162675 /src
parentca5f4faba7859c9cc32351eaa134f39c3bb5a9d1 (diff)
downloadbedrock-core-b0d04c9b28efc90bc6f1cfcc6d2c4d3e646099fb.zip
Simplify conversion of Rust bool to Bedrock bool
The new subtract implementation should be a lot more efficient because it avoids branching.
Diffstat (limited to 'src')
-rw-r--r--src/processor.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/processor.rs b/src/processor.rs
index bc16f01..dc55e4b 100644
--- a/src/processor.rs
+++ b/src/processor.rs
@@ -27,8 +27,8 @@ impl <
macro_rules! RPSH2 { ($x:expr,$y:expr) => { WPSH1!($x); WPSH1!($y); }; }
macro_rules! WPSHD { ($d:expr) => { self.wst.push_u16($d) }; }
macro_rules! RPSHD { ($d:expr) => { self.rst.push_u16($d) }; }
- macro_rules! WPSHB { ($x:expr) => { self.wst.push_u8(if $x {0xff} else {0x00}) }; }
- macro_rules! RPSHB { ($x:expr) => { self.rst.push_u8(if $x {0xff} else {0x00}) }; }
+ macro_rules! WPSHB { ($x:expr) => { self.wst.push_u8(0u8.wrapping_sub($x as u8)) }; }
+ macro_rules! RPSHB { ($x:expr) => { self.rst.push_u8(0u8.wrapping_sub($x as u8)) }; }
macro_rules! WPOP1 { ($x:ident) => { let $x = self.wst.pop_u8(); }; }
macro_rules! RPOP1 { ($x:ident) => { let $x = self.rst.pop_u8(); }; }