From 21489a0a1b465e89d73b86689dc4b8a2a40610f9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 15 Sep 2026 18:03:36 +0200 Subject: xixanta: simplify evaluate_hexadecimal() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'size' variable can be initialized directly from the value we get from the match statement below. I was probably thinking more on the style of C, but the latest Rust stable channel complained about this. Signed-off-by: Miquel Sabaté Solà --- lib/xixanta/src/assembler.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 04ecaef..afd8429 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -2119,30 +2119,28 @@ impl<'a> Assembler<'a> { fn evaluate_hexadecimal(&mut self, node: &PNode) -> Result { let mut chars = node.value.value.chars(); let mut bytes = [0, 0, 0]; - let size: u8; - - match node.value.value.len() { + let size: u8 = match node.value.value.len() { 1 => { bytes[0] = self.char_to_hex(chars.next(), node)?; - size = 1; + 1 } 2 => { bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 1; + 1 } 3 => { bytes[1] = self.char_to_hex(chars.next(), node)?; bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 2; + 2 } 4 => { bytes[1] = self.char_to_hex(chars.next(), node)? * 16; bytes[1] += self.char_to_hex(chars.next(), node)?; bytes[0] = self.char_to_hex(chars.next(), node)? * 16; bytes[0] += self.char_to_hex(chars.next(), node)?; - size = 2; + 2 } _ => { if self.evaluate_variable(node).is_ok() { @@ -2165,7 +2163,7 @@ impl<'a> Assembler<'a> { global: false, }); } - } + }; Ok(Bundle { bytes, -- cgit v1.2.3