LibJS: Don't convert to UTF-8 in order to compare two UTF-16 strings

If we have two PrimitiveString objects that are both backed by UTF-16
data, we don't have to convert them to UTF-8 for equality checking.
Just compare the underlying UTF-16 data. :^)
This commit is contained in:
Andreas Kling 2025-04-10 12:18:08 +02:00 committed by Andreas Kling
commit d78e3590d5
Notes: github-actions[bot] 2025-04-12 09:08:53 +00:00
3 changed files with 14 additions and 1 deletions

View file

@ -2225,7 +2225,7 @@ bool same_value_non_number(Value lhs, Value rhs)
// 5. If x is a String, then
if (lhs.is_string()) {
// a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
return lhs.as_string().utf8_string_view() == rhs.as_string().utf8_string_view();
return lhs.as_string() == rhs.as_string();
}
// 3. If x is undefined, return true.