From bb41b209a6de5c0d9338a640c144dadc9b719f59 Mon Sep 17 00:00:00 2001 From: David Craven Date: Mon, 20 Nov 2017 14:14:01 +0100 Subject: [PATCH] Read bits only once. --- src/csr.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/csr.rs b/src/csr.rs index 43f6ea8..07214e0 100644 --- a/src/csr.rs +++ b/src/csr.rs @@ -283,8 +283,9 @@ impl mcause::R { #[inline(always)] /// Trap Cause pub fn cause(&self) -> Trap { - let code = self.bits() & !(1 << 31); - match self.bits() & (1 << 31) == 1 << 31 { + let bits = self.bits(); + let code = bits & !(1 << 31); + match bits & (1 << 31) == 1 << 31 { true => Trap::Interrupt(Interrupt::from(code)), false => Trap::Exception(Exception::from(code)), }