Skip to content

Commit d8d583d

Browse files
committed
snapshot the inlined result
1 parent 9e638ae commit d8d583d

File tree

2 files changed

+46
-38
lines changed

2 files changed

+46
-38
lines changed

lib/es6/belt_internalAVLset.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import * as Curry from "./curry.js";
44
import * as Caml_option from "./caml_option.js";
55
import * as Belt_SortArray from "./belt_SortArray.js";
66

7-
function treeHeight(n) {
8-
if (n !== undefined) {
9-
return n.h;
10-
} else {
11-
return 0;
12-
}
13-
}
14-
157
function copy(n) {
168
if (n !== undefined) {
179
return {
@@ -368,7 +360,11 @@ function checkInvariantInternal(_v) {
368360
}
369361
var l = v.l;
370362
var r = v.r;
371-
var diff = treeHeight(l) - treeHeight(r) | 0;
363+
var diff = (
364+
l !== undefined ? l.h : 0
365+
) - (
366+
r !== undefined ? r.h : 0
367+
) | 0;
372368
if (!(diff <= 2 && diff >= -2)) {
373369
throw new Error("File \"belt_internalAVLset.ml\", line 288, characters 6-12");
374370
}
@@ -732,12 +728,15 @@ function rotateWithLeftChild(k2) {
732728
var k1 = k2.l;
733729
k2.l = k1.r;
734730
k1.r = k2;
735-
var hlk2 = treeHeight(k2.l);
736-
var hrk2 = treeHeight(k2.r);
731+
var n = k2.l;
732+
var hlk2 = n !== undefined ? n.h : 0;
733+
var n$1 = k2.r;
734+
var hrk2 = n$1 !== undefined ? n$1.h : 0;
737735
k2.h = (
738736
hlk2 > hrk2 ? hlk2 : hrk2
739737
) + 1 | 0;
740-
var hlk1 = treeHeight(k1.l);
738+
var n$2 = k1.l;
739+
var hlk1 = n$2 !== undefined ? n$2.h : 0;
741740
var hk2 = k2.h;
742741
k1.h = (
743742
hlk1 > hk2 ? hlk1 : hk2
@@ -749,12 +748,15 @@ function rotateWithRightChild(k1) {
749748
var k2 = k1.r;
750749
k1.r = k2.l;
751750
k2.l = k1;
752-
var hlk1 = treeHeight(k1.l);
753-
var hrk1 = treeHeight(k1.r);
751+
var n = k1.l;
752+
var hlk1 = n !== undefined ? n.h : 0;
753+
var n$1 = k1.r;
754+
var hrk1 = n$1 !== undefined ? n$1.h : 0;
754755
k1.h = (
755756
hlk1 > hrk1 ? hlk1 : hrk1
756757
) + 1 | 0;
757-
var hrk2 = treeHeight(k2.r);
758+
var n$2 = k2.r;
759+
var hrk2 = n$2 !== undefined ? n$2.h : 0;
758760
var hk1 = k1.h;
759761
k2.h = (
760762
hrk2 > hk1 ? hrk2 : hk1
@@ -777,8 +779,10 @@ function doubleWithRightChild(k2) {
777779
}
778780

779781
function heightUpdateMutate(t) {
780-
var hlt = treeHeight(t.l);
781-
var hrt = treeHeight(t.r);
782+
var n = t.l;
783+
var hlt = n !== undefined ? n.h : 0;
784+
var n$1 = t.r;
785+
var hrt = n$1 !== undefined ? n$1.h : 0;
782786
t.h = (
783787
hlt > hrt ? hlt : hrt
784788
) + 1 | 0;
@@ -788,8 +792,8 @@ function heightUpdateMutate(t) {
788792
function balMutate(nt) {
789793
var l = nt.l;
790794
var r = nt.r;
791-
var hl = treeHeight(l);
792-
var hr = treeHeight(r);
795+
var hl = l !== undefined ? l.h : 0;
796+
var hr = r !== undefined ? r.h : 0;
793797
if (hl > (2 + hr | 0)) {
794798
var ll = l.l;
795799
var lr = l.r;

lib/js/belt_internalAVLset.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ var Curry = require("./curry.js");
44
var Caml_option = require("./caml_option.js");
55
var Belt_SortArray = require("./belt_SortArray.js");
66

7-
function treeHeight(n) {
8-
if (n !== undefined) {
9-
return n.h;
10-
} else {
11-
return 0;
12-
}
13-
}
14-
157
function copy(n) {
168
if (n !== undefined) {
179
return {
@@ -368,7 +360,11 @@ function checkInvariantInternal(_v) {
368360
}
369361
var l = v.l;
370362
var r = v.r;
371-
var diff = treeHeight(l) - treeHeight(r) | 0;
363+
var diff = (
364+
l !== undefined ? l.h : 0
365+
) - (
366+
r !== undefined ? r.h : 0
367+
) | 0;
372368
if (!(diff <= 2 && diff >= -2)) {
373369
throw new Error("File \"belt_internalAVLset.ml\", line 288, characters 6-12");
374370
}
@@ -732,12 +728,15 @@ function rotateWithLeftChild(k2) {
732728
var k1 = k2.l;
733729
k2.l = k1.r;
734730
k1.r = k2;
735-
var hlk2 = treeHeight(k2.l);
736-
var hrk2 = treeHeight(k2.r);
731+
var n = k2.l;
732+
var hlk2 = n !== undefined ? n.h : 0;
733+
var n$1 = k2.r;
734+
var hrk2 = n$1 !== undefined ? n$1.h : 0;
737735
k2.h = (
738736
hlk2 > hrk2 ? hlk2 : hrk2
739737
) + 1 | 0;
740-
var hlk1 = treeHeight(k1.l);
738+
var n$2 = k1.l;
739+
var hlk1 = n$2 !== undefined ? n$2.h : 0;
741740
var hk2 = k2.h;
742741
k1.h = (
743742
hlk1 > hk2 ? hlk1 : hk2
@@ -749,12 +748,15 @@ function rotateWithRightChild(k1) {
749748
var k2 = k1.r;
750749
k1.r = k2.l;
751750
k2.l = k1;
752-
var hlk1 = treeHeight(k1.l);
753-
var hrk1 = treeHeight(k1.r);
751+
var n = k1.l;
752+
var hlk1 = n !== undefined ? n.h : 0;
753+
var n$1 = k1.r;
754+
var hrk1 = n$1 !== undefined ? n$1.h : 0;
754755
k1.h = (
755756
hlk1 > hrk1 ? hlk1 : hrk1
756757
) + 1 | 0;
757-
var hrk2 = treeHeight(k2.r);
758+
var n$2 = k2.r;
759+
var hrk2 = n$2 !== undefined ? n$2.h : 0;
758760
var hk1 = k1.h;
759761
k2.h = (
760762
hrk2 > hk1 ? hrk2 : hk1
@@ -777,8 +779,10 @@ function doubleWithRightChild(k2) {
777779
}
778780

779781
function heightUpdateMutate(t) {
780-
var hlt = treeHeight(t.l);
781-
var hrt = treeHeight(t.r);
782+
var n = t.l;
783+
var hlt = n !== undefined ? n.h : 0;
784+
var n$1 = t.r;
785+
var hrt = n$1 !== undefined ? n$1.h : 0;
782786
t.h = (
783787
hlt > hrt ? hlt : hrt
784788
) + 1 | 0;
@@ -788,8 +792,8 @@ function heightUpdateMutate(t) {
788792
function balMutate(nt) {
789793
var l = nt.l;
790794
var r = nt.r;
791-
var hl = treeHeight(l);
792-
var hr = treeHeight(r);
795+
var hl = l !== undefined ? l.h : 0;
796+
var hr = r !== undefined ? r.h : 0;
793797
if (hl > (2 + hr | 0)) {
794798
var ll = l.l;
795799
var lr = l.r;

0 commit comments

Comments
 (0)