Skip to content

Instantly share code, notes, and snippets.

@cemerick
Created January 16, 2019 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerick/4de090c89df95c2cc86deedac815e053 to your computer and use it in GitHub Desktop.
Save cemerick/4de090c89df95c2cc86deedac815e053 to your computer and use it in GitHub Desktop.
// tweaked version of `bsc` output to use objects instead of arrays to represent records, runs in ~5.5s under node v10.x.x
// Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE
'use strict';
var Pervasives = require("bs-platform/lib/js/pervasives.js");
var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js");
function r(lx, by, rx, ty) {
return {lx:lx, by:by, rx:rx, ty:ty}
}
function union (r1, r2) {
return r(Caml_primitive.caml_float_min(r1.lx, r2.lx)
,Caml_primitive.caml_float_min(r1.by, r2.by)
,Caml_primitive.caml_float_max(r1.rx, r2.rx)
,Caml_primitive.caml_float_max(r1.ty, r2.ty));
}
var Rectangle = /* module */[
/* r */r,
/* union */union
];
var rect = r(
/* lx */25,
/* by */25,
/* rx */200,
/* ty */200
);
for(var i = 0; i <= 1000000000; ++i){
rect = union(rect, r(20, 0, 100, i));
}
console.log(Pervasives.string_of_float(rect.ty));
var lim = 1000000000;
exports.Rectangle = Rectangle;
exports.lim = lim;
/* Not a pure module */
// untouched output, runs ~10s under node v10.x.x
// Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE
'use strict';
var Pervasives = require("bs-platform/lib/js/pervasives.js");
var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js");
function r(lx, by, rx, ty) {
return /* record */[
/* lx */lx,
/* by */by,
/* rx */rx,
/* ty */ty
];
}
function union(param, param$1) {
return r(Caml_primitive.caml_float_min(param[/* lx */0], param$1[/* lx */0]), Caml_primitive.caml_float_min(param[/* by */1], param$1[/* by */1]), Caml_primitive.caml_float_max(param[/* rx */2], param$1[/* rx */2]), Caml_primitive.caml_float_max(param[/* ty */3], param$1[/* ty */3]));
}
var Rectangle = /* module */[
/* r */r,
/* union */union
];
var rect = /* record */[
/* lx */25,
/* by */25,
/* rx */200,
/* ty */200
];
for(var i = 0; i <= 1000000000; ++i){
rect = union(rect, r(20, 0, 100, i));
}
console.log(Pervasives.string_of_float(rect[/* ty */3]));
var lim = 1000000000;
exports.Rectangle = Rectangle;
exports.lim = lim;
/* Not a pure module */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment