From a0fc2a7e44ef9789a74cc9be0146961d963179db Mon Sep 17 00:00:00 2001 From: Richard Leek Date: Sun, 13 Oct 2024 20:01:39 +0200 Subject: [PATCH] Remove unused variable in sequencer For fixed size arrays just use remaining for size 1 --- build.rs | 12 ++++++++---- src/packet/sequencer.rs | 3 +-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index 13a367d..d0ffd7f 100644 --- a/build.rs +++ b/build.rs @@ -1399,10 +1399,14 @@ fn generate_inner_array_deserialize( length )); } else if let Some(size) = get_fixed_type_size(&array.data_type, structs, enums) { - code.push_str(&format!( - " let num_items = reader.remaining() / {};\n", - size - )); + if size == 1 { + code.push_str(" let num_items = reader.remaining();\n"); + } else { + code.push_str(&format!( + " let num_items = reader.remaining() / {};\n", + size + )); + } code.push_str(" for _ in 0..num_items {\n"); } else { code.push_str(" while reader.remaining() > 0 {\n"); diff --git a/src/packet/sequencer.rs b/src/packet/sequencer.rs index 33da62e..12ca26f 100644 --- a/src/packet/sequencer.rs +++ b/src/packet/sequencer.rs @@ -30,8 +30,7 @@ impl Sequencer { /// returns the next sequence value pub fn next_sequence(&mut self) -> i32 { self.counter = (self.counter + 1) % 10; - let result = self.start + self.counter; - result + self.start + self.counter } /// sets a new starting value for the sequencer