Skip to content

Commit 85f64ea

Browse files
committed
Revert changes that have become unnecessary after 45924dc
1 parent 45924dc commit 85f64ea

File tree

8 files changed

+17
-69
lines changed

8 files changed

+17
-69
lines changed

jscomp/runtime/caml_obj.ml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ let caml_lazy_make (fn : _ -> _) =
119119
In most cases, rec value comes from record/modules,
120120
whose tag is 0, we optimize that case
121121
*)
122-
let caml_update_dummy0 (x : Caml_obj_extern.t) (y : Caml_obj_extern.t) : unit =
122+
let caml_update_dummy (x : Caml_obj_extern.t) (y : Caml_obj_extern.t) : unit =
123123
(* let len = Caml_obj_extern.length y in
124124
for i = 0 to len - 1 do
125125
Array.unsafe_set x i (Caml_obj_extern.field y i)
@@ -137,16 +137,6 @@ let caml_update_dummy0 (x : Caml_obj_extern.t) (y : Caml_obj_extern.t) : unit =
137137
(* [set_length] seems redundant here given that it is initialized as an array
138138
*)
139139

140-
let () = if [1] == [1] then Js.log(caml_update_dummy0)
141-
142-
let caml_update_dummy : Caml_obj_extern.t -> Caml_obj_extern.t -> unit = fun%raw x y-> {|
143-
if (Array.isArray(x) && Array.isArray(y)) { return caml_update_dummy0(x,y) }
144-
else {
145-
return Object.assign(x, y)
146-
}
147-
|}
148-
149-
150140
type 'a selector = 'a -> 'a -> 'a
151141

152142
module O = struct

jscomp/runtime/caml_obj_extern.ml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,8 @@ external length : t -> int = "#obj_length"
3636
(** The same as {!Obj.set_tag} *)
3737
external set_tag : t -> int -> unit = "tag" [@@bs.set]
3838

39+
external size_of_t : t -> 'a Js.undefined =
40+
"length" [@@bs.get]
3941

40-
(* external size_of_t : t -> 'a Js.undefined =
41-
"length" [@@bs.get] *)
42-
43-
(* polymorphic variants are still arrays *)
44-
let size_of_t : t -> 'a Js.undefined = fun%raw o -> {|
45-
return Array.isArray(o) ? o.length : Object.keys(o).length
46-
|}
47-
48-
let length : t -> int = fun%raw o -> {|
49-
return Array.isArray(o) ? o.length : Object.keys(o).length
50-
|}
5142

5243
external magic : 'a -> 'b = "%identity"

jscomp/test/undef_regression_test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
'use strict';
22

3-
var Caml_obj_extern = require("../../lib/js/caml_obj_extern.js");
43

54
function f(obj) {
65
if (typeof obj === "function") {
76
return /* () */0;
87
} else {
9-
var size = Caml_obj_extern.size_of_t(obj);
8+
var size = obj.length;
109
if (size !== undefined) {
1110
console.log(size);
1211
return /* () */0;

lib/js/caml_hash.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
var Caml_obj_extern = require("./caml_obj_extern.js");
43
var Caml_hash_primitive = require("./caml_hash_primitive.js");
54
var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js");
65

@@ -78,7 +77,7 @@ function caml_hash(count, _limit, seed, obj) {
7877
];
7978
}
8079
if (typeof obj$1 !== "function") {
81-
var size = Caml_obj_extern.size_of_t(obj$1);
80+
var size = obj$1.length;
8281
if (size !== undefined) {
8382
var obj_tag = /* XXX */obj$1.tag;
8483
var tag = (size << 10) | obj_tag;

lib/js/caml_module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ function update_mod(shape, o, n) {
103103

104104
exports.init_mod = init_mod;
105105
exports.update_mod = update_mod;
106-
/* Caml_obj Not a pure module */
106+
/* No side effect */

lib/js/caml_obj.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
var Block = require("./block.js");
44
var Caml_primitive = require("./caml_primitive.js");
5-
var Caml_obj_extern = require("./caml_obj_extern.js");
65
var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js");
76

87
function caml_obj_block(tag, size) {
@@ -12,7 +11,7 @@ function caml_obj_block(tag, size) {
1211
}
1312

1413
function caml_obj_dup(x) {
15-
var len = Caml_obj_extern.length(x);
14+
var len = x.length | 0;
1615
var v = new Array(len);
1716
for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){
1817
v[i] = x[i];
@@ -22,7 +21,7 @@ function caml_obj_dup(x) {
2221
}
2322

2423
function caml_obj_truncate(x, new_size) {
25-
var len = Caml_obj_extern.length(x);
24+
var len = x.length | 0;
2625
if (new_size <= 0 || new_size > len) {
2726
throw [
2827
Caml_builtin_exceptions.invalid_argument,
@@ -50,8 +49,8 @@ function caml_lazy_make(fn) {
5049
return block;
5150
}
5251

53-
function caml_update_dummy0(x, y) {
54-
var len = Caml_obj_extern.length(y);
52+
function caml_update_dummy(x, y) {
53+
var len = y.length | 0;
5554
for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){
5655
x[i] = y[i];
5756
}
@@ -64,23 +63,6 @@ function caml_update_dummy0(x, y) {
6463
}
6564
}
6665

67-
if (Block.__("::", [
68-
1,
69-
"[]"
70-
]) === Block.__("::", [
71-
1,
72-
"[]"
73-
])) {
74-
console.log(caml_update_dummy0);
75-
}
76-
77-
function caml_update_dummy (x,y){
78-
if (Array.isArray(x) && Array.isArray(y)) { return caml_update_dummy0(x,y) }
79-
else {
80-
return Object.assign(x, y)
81-
}
82-
};
83-
8466
function for_in (o,foo){
8567
for (var x in o) { foo(x) }
8668
};
@@ -193,8 +175,8 @@ function caml_compare(_a, _b) {
193175
return 1;
194176
}
195177
} else {
196-
var len_a = Caml_obj_extern.length(a);
197-
var len_b = Caml_obj_extern.length(b);
178+
var len_a = a.length | 0;
179+
var len_b = b.length | 0;
198180
if (len_a === len_b) {
199181
if (Array.isArray(a)) {
200182
var a$1 = a;
@@ -363,8 +345,8 @@ function caml_equal(_a, _b) {
363345
} else if (tag_a === 256) {
364346
return a[1] === b[1];
365347
} else {
366-
var len_a = Caml_obj_extern.length(a);
367-
var len_b = Caml_obj_extern.length(b);
348+
var len_a = a.length | 0;
349+
var len_b = b.length | 0;
368350
if (len_a === len_b) {
369351
if (Array.isArray(a)) {
370352
var a$1 = a;
@@ -509,4 +491,4 @@ exports.caml_lessequal = caml_lessequal;
509491
exports.caml_min = caml_min;
510492
exports.caml_max = caml_max;
511493
exports.caml_obj_set_tag = caml_obj_set_tag;
512-
/* Not a pure module */
494+
/* No side effect */

lib/js/caml_obj_extern.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
'use strict';
2-
3-
4-
function size_of_t (o){
5-
return Array.isArray(o) ? o.length : Object.keys(o).length
6-
};
7-
8-
function length (o){
9-
return Array.isArray(o) ? o.length : Object.keys(o).length
10-
};
11-
12-
exports.size_of_t = size_of_t;
13-
exports.length = length;
14-
/* No side effect */
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

lib/js/caml_weak.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ exports.caml_weak_get = caml_weak_get;
4141
exports.caml_weak_get_copy = caml_weak_get_copy;
4242
exports.caml_weak_check = caml_weak_check;
4343
exports.caml_weak_blit = caml_weak_blit;
44-
/* Caml_obj Not a pure module */
44+
/* No side effect */

0 commit comments

Comments
 (0)