# HG changeset patch # User Emmanuel Gil Peyrot # Date 1565615419 -7200 # Node ID 1bb8b34dbd32e074c9421b6d950067a51547a858 # Parent 140ee7de6d9011dd0853705a3c41219f7c6fb724 Don’t allocate a Vec while reading a String in ECL. diff --git a/src/th06/ecl.rs b/src/th06/ecl.rs --- a/src/th06/ecl.rs +++ b/src/th06/ecl.rs @@ -135,7 +135,7 @@ macro_rules! declare_main_instructions { /// Parse a SHIFT_JIS byte string of length 34 into a String. pub fn le_String(i: &[u8]) -> IResult<&[u8], String> { assert_eq!(i.len(), 34); - let data = i.splitn(2, |c| *c == b'\0').collect::>()[0]; + let data = i.splitn(2, |c| *c == b'\0').nth(0).unwrap(); let (string, encoding, replaced) = SHIFT_JIS.decode(data); Ok((&i[34..], string.into_owned())) }