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

LibJS: Rename to_{i32,size_t}() to as_{i32,size_t}() for clarity

As these parameter-less overloads don't change the value's type and
just assume Type::Number, naming them as_i32() and as_size_t() is more
appropriate.
This commit is contained in:
Linus Groh 2020-05-18 08:59:35 +01:00 committed by Andreas Kling
parent 014cb1a55b
commit 36996bd720
6 changed files with 28 additions and 25 deletions

View file

@ -58,12 +58,12 @@ Value ArrayConstructor::call(Interpreter& interpreter)
if (interpreter.argument_count() == 1 && interpreter.argument(0).is_number()) {
auto array_length_value = interpreter.argument(0);
if (!array_length_value.is_integer() || array_length_value.to_i32() < 0) {
if (!array_length_value.is_integer() || array_length_value.as_i32() < 0) {
interpreter.throw_exception<TypeError>("Invalid array length");
return {};
}
auto* array = Array::create(interpreter.global_object());
array->elements().resize(array_length_value.to_i32());
array->elements().resize(array_length_value.as_i32());
return array;
}