mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
LibJS: Remove ByteString internals from PrimitiveString
PrimitiveString is now internally either UTF-8, UTF-16, or both. We no longer convert them to/from ByteString anywhere, nor does VM have a ByteString cache.
This commit is contained in:
parent
f05b0bfd5f
commit
c71772126f
Notes:
github-actions[bot]
2025-03-28 16:32:54 +00:00
Author: https://github.com/awesomekling
Commit: c71772126f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4142
Reviewed-by: https://github.com/trflynn89
14 changed files with 49 additions and 118 deletions
|
@ -724,7 +724,7 @@ ThrowCompletionOr<Value> Value::to_number_slow_case(VM& vm) const
|
|||
return Value(as_bool() ? 1 : 0);
|
||||
// 6. If argument is a String, return StringToNumber(argument).
|
||||
case STRING_TAG:
|
||||
return string_to_number(as_string().byte_string());
|
||||
return string_to_number(as_string().utf8_string_view());
|
||||
// 7. Assert: argument is an Object.
|
||||
case OBJECT_TAG: {
|
||||
// 8. Let primValue be ? ToPrimitive(argument, number).
|
||||
|
@ -778,7 +778,7 @@ ThrowCompletionOr<GC::Ref<BigInt>> Value::to_bigint(VM& vm) const
|
|||
return primitive.as_bigint();
|
||||
case STRING_TAG: {
|
||||
// 1. Let n be ! StringToBigInt(prim).
|
||||
auto bigint = string_to_bigint(vm, primitive.as_string().byte_string());
|
||||
auto bigint = string_to_bigint(vm, primitive.as_string().utf8_string_view());
|
||||
|
||||
// 2. If n is undefined, throw a SyntaxError exception.
|
||||
if (!bigint.has_value())
|
||||
|
@ -2226,7 +2226,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().byte_string() == rhs.as_string().byte_string();
|
||||
return lhs.as_string().utf8_string_view() == rhs.as_string().utf8_string_view();
|
||||
}
|
||||
|
||||
// 3. If x is undefined, return true.
|
||||
|
@ -2307,7 +2307,7 @@ ThrowCompletionOr<bool> is_loosely_equal(VM& vm, Value lhs, Value rhs)
|
|||
// 7. If Type(x) is BigInt and Type(y) is String, then
|
||||
if (lhs.is_bigint() && rhs.is_string()) {
|
||||
// a. Let n be StringToBigInt(y).
|
||||
auto bigint = string_to_bigint(vm, rhs.as_string().byte_string());
|
||||
auto bigint = string_to_bigint(vm, rhs.as_string().utf8_string_view());
|
||||
|
||||
// b. If n is undefined, return false.
|
||||
if (!bigint.has_value())
|
||||
|
@ -2388,8 +2388,8 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
|
||||
// 3. If px is a String and py is a String, then
|
||||
if (x_primitive.is_string() && y_primitive.is_string()) {
|
||||
auto x_string = x_primitive.as_string().byte_string();
|
||||
auto y_string = y_primitive.as_string().byte_string();
|
||||
auto x_string = x_primitive.as_string().utf8_string_view();
|
||||
auto y_string = y_primitive.as_string().utf8_string_view();
|
||||
|
||||
Utf8View x_code_points { x_string };
|
||||
Utf8View y_code_points { y_string };
|
||||
|
@ -2424,7 +2424,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
// a. If px is a BigInt and py is a String, then
|
||||
if (x_primitive.is_bigint() && y_primitive.is_string()) {
|
||||
// i. Let ny be StringToBigInt(py).
|
||||
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().byte_string());
|
||||
auto y_bigint = string_to_bigint(vm, y_primitive.as_string().utf8_string_view());
|
||||
|
||||
// ii. If ny is undefined, return undefined.
|
||||
if (!y_bigint.has_value())
|
||||
|
@ -2439,7 +2439,7 @@ ThrowCompletionOr<TriState> is_less_than(VM& vm, Value lhs, Value rhs, bool left
|
|||
// b. If px is a String and py is a BigInt, then
|
||||
if (x_primitive.is_string() && y_primitive.is_bigint()) {
|
||||
// i. Let nx be StringToBigInt(px).
|
||||
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().byte_string());
|
||||
auto x_bigint = string_to_bigint(vm, x_primitive.as_string().utf8_string_view());
|
||||
|
||||
// ii. If nx is undefined, return undefined.
|
||||
if (!x_bigint.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue