From 248b05c992286bb14d9a65eb7bbaca574a543075 Mon Sep 17 00:00:00 2001 From: Skgland Date: Tue, 18 Nov 2025 22:01:42 +0100 Subject: [PATCH] use as_bytes().to_vec() instead of bytes().collect() copying a slice into a vec should be easier to optimize by the complier than collecting a byte iteration into a vec --- src/machine/system_calls.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 5fc4088b..4e1797a9 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -3303,7 +3303,7 @@ impl Machine { bytes.push(c as u8); } } else { - bytes = string.as_str().bytes().collect(); + bytes = string.as_str().as_bytes().to_vec(); } match stream.write_all(&bytes) { @@ -4420,7 +4420,7 @@ impl Machine { let address_data = self.deref_register(5); let mut bytes: Vec = Vec::new(); if let Some(string) = self.machine_st.value_to_str_like(address_data) { - bytes = string.as_str().bytes().collect(); + bytes = string.as_str().as_bytes().to_vec(); } let stub_gen = || functor_stub(atom!("http_open"), 3); @@ -9309,7 +9309,7 @@ impl Machine { let data = self.machine_st.value_to_str_like(data_arg).unwrap(); match encoding { - atom!("utf8") => data.as_str().bytes().collect(), + atom!("utf8") => data.as_str().as_bytes().to_vec(), atom!("octet") => data.as_str().chars().map(|c| c as u8).collect(), _ => { unreachable!() -- 2.54.0