From 93647f03139d8ad4b783bbae08a4097d0ac2d422 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 3 Nov 2021 14:29:05 +0000 Subject: [PATCH] acpi_tables: aml: Implement Aml::append_aml_bytes() for Usize Since we know all the numerical types now have implementations of Aml::append_aml_bytes() we can use that directly. Signed-off-by: Rob Bradford --- acpi_tables/src/aml.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/acpi_tables/src/aml.rs b/acpi_tables/src/aml.rs index 3ec6171a4..11c3ac368 100644 --- a/acpi_tables/src/aml.rs +++ b/acpi_tables/src/aml.rs @@ -260,23 +260,19 @@ impl Aml for EisaName { } } -fn create_integer(v: usize) -> Vec { - if v <= u8::max_value().into() { - (v as u8).to_aml_bytes() - } else if v <= u16::max_value().into() { - (v as u16).to_aml_bytes() - } else if v <= u32::max_value() as usize { - (v as u32).to_aml_bytes() - } else { - (v as u64).to_aml_bytes() - } -} - pub type Usize = usize; impl Aml for Usize { - fn to_aml_bytes(&self) -> Vec { - create_integer(*self) + fn append_aml_bytes(&self, bytes: &mut Vec) { + if *self <= u8::max_value().into() { + (*self as u8).append_aml_bytes(bytes) + } else if *self <= u16::max_value().into() { + (*self as u16).append_aml_bytes(bytes) + } else if *self <= u32::max_value() as usize { + (*self as u32).append_aml_bytes(bytes) + } else { + (*self as u64).append_aml_bytes(bytes) + } } }