Skip to content

Commit

Permalink
luau: use simd accelerated utf8 validation in map_computed_value
Browse files Browse the repository at this point in the history
used in hot loop
  • Loading branch information
jqnatividad committed Nov 23, 2023
1 parent 3c1a3d7 commit c20798b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cmd/luau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,11 @@ fn map_computedvalue(
) -> Result<(), CliError> {
match computed_value {
Value::String(string) => {
record.push_field(&string.to_string_lossy());
if let Ok(utf8) = simdutf8::basic::from_utf8(string.as_bytes()) {
record.push_field(utf8);
} else {
record.push_field(&string.to_string_lossy());
}
},
Value::Number(number) => {
let mut buffer = ryu::Buffer::new();
Expand Down Expand Up @@ -1282,7 +1286,7 @@ fn map_computedvalue(
Value::String(strval) => record.push_field(&strval.to_string_lossy()),
Value::Number(number) => record.push_field(nbuffer.format(number)),
Value::Boolean(boolean) => {
record.push_field(if boolean { "true" } else { "false" })
record.push_field(if boolean { "true" } else { "false" });
},
Value::Nil => record.push_field(""),
_ => {
Expand Down

0 comments on commit c20798b

Please sign in to comment.