Unify single-char and multi-char CStrUnit::Char handling.

The two cases are equivalent. C string literals aren't common so there
is no performance need here.
This commit is contained in:
Nicholas Nethercote 2023-12-13 09:46:21 +11:00
parent 29c5158ef5
commit a50efe2653

View File

@ -161,7 +161,6 @@ pub fn from_token_lit(lit: token::Lit) -> Result<LitKind, LitError> {
error = Err(LitError::NulInCStr(span));
}
Ok(CStrUnit::Byte(b)) => buf.push(b),
Ok(CStrUnit::Char(c)) if c.len_utf8() == 1 => buf.push(c as u8),
Ok(CStrUnit::Char(c)) => {
buf.extend_from_slice(c.encode_utf8(&mut [0; 4]).as_bytes())
}