Skip to content

Commit 3afe16c

Browse files
committed
reduce the usage of Obj.field
1 parent 92fd541 commit 3afe16c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

jscomp/runtime/caml_obj.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,17 @@ let rec caml_equal (a : Obj.t) (b : Obj.t) : bool =
309309
let len_a = Obj.size a in
310310
let len_b = Obj.size b in
311311
if len_a = len_b then
312-
if O.isArray(a)
313-
then aux_equal_length a b 0 len_a
312+
if O.isArray a
313+
then aux_equal_length (Obj.magic a : Obj.t array) (Obj.magic b : Obj.t array) 0 len_a
314314
else if [%raw{|a instanceof Date && b instanceof Date|}] then
315315
not (Js.unsafe_gt a b || Js.unsafe_lt a b)
316316
else aux_obj_equal a b
317317
else false
318-
and aux_equal_length (a : Obj.t) (b : Obj.t) i same_length =
318+
and aux_equal_length (a : Obj.t array) (b : Obj.t array) i same_length =
319319
if i = same_length then
320320
true
321321
else
322-
caml_equal (Obj.field a i) (Obj.field b i)
322+
caml_equal (Caml_array_extern.unsafe_get a i) (Caml_array_extern.unsafe_get b i)
323323
&& aux_equal_length a b (i + 1) same_length
324324
and aux_obj_equal (a: Obj.t) (b: Obj.t) =
325325
let result = ref true in

0 commit comments

Comments
 (0)