1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

LibJS: Use u64 for the length parameter in Array::create()

This doesn't matter per se as the value is immediately validated to be
in the 0 to 2^32 - 1 range, but it avoids having to cast a number that
potentially doesn't fit into a size_t into one at the call site. More
often than not, array-like lengths are only validated to be <= 2^52 - 1,
i.e. MAX_SAFE_INTEGER.

This is fully backwards compatible with existing code as a size_t always
fits into an u64, but an u64 might not always fit into a size_t.
This commit is contained in:
Linus Groh 2022-07-03 16:26:55 +02:00
parent 65eb1ee67a
commit 5927cdd9c5
2 changed files with 2 additions and 2 deletions

View file

@ -17,7 +17,7 @@
namespace JS {
// 10.4.2.2 ArrayCreate ( length [ , proto ] ), https://tc39.es/ecma262/#sec-arraycreate
ThrowCompletionOr<Array*> Array::create(GlobalObject& global_object, size_t length, Object* prototype)
ThrowCompletionOr<Array*> Array::create(GlobalObject& global_object, u64 length, Object* prototype)
{
auto& vm = global_object.vm();