summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/ArrayConstructor.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-18 08:59:35 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-18 10:21:51 +0200
commit36996bd720e0ead315dea5057be9f5551af4a787 (patch)
treed669c5fac275bca007d2be5477c8554f3bd350cd /Libraries/LibJS/Runtime/ArrayConstructor.cpp
parent014cb1a55b70bfc2c5defbdeee3e13827f463e32 (diff)
downloadserenity-36996bd720e0ead315dea5057be9f5551af4a787.zip
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.
Diffstat (limited to 'Libraries/LibJS/Runtime/ArrayConstructor.cpp')
-rw-r--r--Libraries/LibJS/Runtime/ArrayConstructor.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
index 3c5b7c07b6..d1423009ff 100644
--- a/Libraries/LibJS/Runtime/ArrayConstructor.cpp
+++ b/Libraries/LibJS/Runtime/ArrayConstructor.cpp
@@ -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;
}