From e915155ca452bb9c731051030b0cbb6883d4809d Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 6 Jul 2021 02:10:58 +0300 Subject: [PATCH] LibJS: Remove impossible check from Array's native length getter/setter Since the object rewrite native property getters/setters are always called with the owning object as the this_value, which in this case is an Array object, and as such this checks are always false. --- Userland/Libraries/LibJS/Runtime/Array.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 50dbccef9d..e7d60de6c2 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -81,14 +81,6 @@ JS_DEFINE_NATIVE_GETTER(Array::length_getter) if (!this_object) return {}; - // TODO: could be incorrect if receiver/this_value is fixed or changed - if (!this_object->is_array()) { - auto value = this_object->internal_get(vm.names.length.to_string_or_symbol(), this_object); - if (vm.exception()) - return {}; - return value; - } - return Value(this_object->indexed_properties().array_like_size()); } @@ -98,14 +90,6 @@ JS_DEFINE_NATIVE_SETTER(Array::length_setter) if (!this_object) return; - // TODO: could be incorrect if receiver/this_value is fixed or changed - if (!this_object->is_array()) { - this_object->define_property(vm.names.length.to_string_or_symbol(), value, default_attributes); - if (vm.exception()) - return; - return; - } - auto length = value.to_number(global_object); if (vm.exception()) return;