From 8ff334f26a2763bdefdd324238bc48a55f0d8fda Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Fri, 1 May 2020 19:24:26 -0400 Subject: [PATCH] we dont need to check that output buffer is valid utf8 --- src/output.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/output.rs b/src/output.rs index 6d35f7e..42344c3 100644 --- a/src/output.rs +++ b/src/output.rs @@ -129,12 +129,11 @@ impl Css { let mut string = Vec::new(); self._inner_pretty_print(&mut string, map, 0)?; if string.iter().any(|s| !s.is_ascii()) { - return Ok(format!( - "@charset \"UTF-8\";\n{}", - String::from_utf8(string)? - )); + return Ok(format!("@charset \"UTF-8\";\n{}", unsafe { + String::from_utf8_unchecked(string) + })); } - Ok(String::from_utf8(string)?) + Ok(unsafe { String::from_utf8_unchecked(string) }) } fn debug(map: &CodeMap, span: Span, message: &str) {