Open
Description
utf8_to_utf16le_bytes
creates a temporary vec which we can avoid. We don't need vec allocations for counting or serializing the utf-16 bytes. For example,
let meta_utf16_len = self.metadata.encode_utf16().count() * 2; // This would count without allocating
// This would serialize UTF-16LE bytes directly to a buffer
fn write_utf16le_to_buffer(buf: &mut Vec<u8>, s: &str) {
for u in s.encode_utf16() {
buf.extend_from_slice(&u.to_le_bytes());
}
}
Originally posted by @utpilla in #261 (comment)