mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibJS: Make TypedArray::element_name return FlyString instead of String
This ensures that comparison between TypedArray names will be essentially free (just a pointer comparison), which will allow us to efficiently implement specification steps like: "24. If srcType is the same as targetType, then" efficiently.
This commit is contained in:
parent
9839e2eeb6
commit
c7a8902746
Notes:
sideshowbarker
2024-07-17 19:08:25 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/c7a8902746 Pull-request: https://github.com/SerenityOS/serenity/pull/12365 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/linusg ✅
3 changed files with 5 additions and 5 deletions
|
@ -28,14 +28,14 @@ static ThrowCompletionOr<ArrayBuffer*> validate_integer_typed_array(GlobalObject
|
|||
auto* buffer = typed_array.viewed_array_buffer();
|
||||
|
||||
// 4. Let typeName be typedArray.[[TypedArrayName]].
|
||||
auto type_name = typed_array.element_name();
|
||||
auto const& type_name = typed_array.element_name();
|
||||
|
||||
// 5. Let type be the Element Type value in Table 72 for typeName.
|
||||
|
||||
// 6. If waitable is true, then
|
||||
if (waitable) {
|
||||
// a. If typeName is not "Int32Array" or "BigInt64Array", throw a TypeError exception.
|
||||
if ((type_name != "Int32Array"sv) && (type_name != "BigInt64Array"sv))
|
||||
if ((type_name != vm.names.Int32Array.as_string()) && (type_name != vm.names.BigInt64Array.as_string()))
|
||||
return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayTypeIsNot, type_name, "Int32 or BigInt64"sv);
|
||||
}
|
||||
// 7. Else,
|
||||
|
|
|
@ -395,7 +395,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
\
|
||||
ClassName::~ClassName() { } \
|
||||
\
|
||||
String ClassName::element_name() const \
|
||||
FlyString const& ClassName::element_name() const \
|
||||
{ \
|
||||
return vm().names.ClassName.as_string(); \
|
||||
} \
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
void set_viewed_array_buffer(ArrayBuffer* array_buffer) { m_viewed_array_buffer = array_buffer; }
|
||||
|
||||
virtual size_t element_size() const = 0;
|
||||
virtual String element_name() const = 0;
|
||||
virtual FlyString const& element_name() const = 0;
|
||||
|
||||
// 25.1.2.6 IsUnclampedIntegerElementType ( type ), https://tc39.es/ecma262/#sec-isunclampedintegerelementtype
|
||||
virtual bool is_unclamped_integer_element_type() const = 0;
|
||||
|
@ -482,7 +482,7 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_create(GlobalObject& global_objec
|
|||
static ThrowCompletionOr<ClassName*> create(GlobalObject&, u32 length); \
|
||||
static ClassName* create(GlobalObject&, u32 length, ArrayBuffer& buffer); \
|
||||
ClassName(Object& prototype, u32 length, ArrayBuffer& array_buffer); \
|
||||
virtual String element_name() const override; \
|
||||
virtual FlyString const& element_name() const override; \
|
||||
}; \
|
||||
class PrototypeName final : public Object { \
|
||||
JS_OBJECT(PrototypeName, Object); \
|
||||
|
|
Loading…
Reference in a new issue