Skip to content

Commit 0d3659f

Browse files
committed
runtime: cleanup
Signed-off-by: Sora Morimoto <[email protected]>
1 parent a93b73b commit 0d3659f

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

biome.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"rules": {
1414
"recommended": true,
1515
"style": {
16-
"noParameterAssign": "off"
16+
"noParameterAssign": "off",
17+
"useNamingConvention": "off",
18+
"useShorthandAssign": "error"
1719
},
1820
"suspicious": {
1921
"noAssignInExpressions": "off",

runtime/bigarray.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function caml_ba_get_size(dims) {
3737
for (let i = 0; i < n_dims; i++) {
3838
if (dims[i] < 0)
3939
caml_invalid_argument("Bigarray.create: negative dimension");
40-
size = size * dims[i];
40+
size *= dims[i];
4141
}
4242
return size;
4343
}
@@ -539,12 +539,12 @@ function caml_ba_sub(ba, ofs, len) {
539539
let changed_dim;
540540
let mul = 1;
541541
if (ba.layout === 0) {
542-
for (let i = 1; i < ba.dims.length; i++) mul = mul * ba.dims[i];
542+
for (let i = 1; i < ba.dims.length; i++) mul *= ba.dims[i];
543543
changed_dim = 0;
544544
} else {
545-
for (let i = 0; i < ba.dims.length - 1; i++) mul = mul * ba.dims[i];
545+
for (let i = 0; i < ba.dims.length - 1; i++) mul *= ba.dims[i];
546546
changed_dim = ba.dims.length - 1;
547-
ofs = ofs - 1;
547+
ofs -= 1;
548548
}
549549
if (ofs < 0 || len < 0 || ofs + len > ba.dims[changed_dim]) {
550550
caml_invalid_argument("Bigarray.sub: bad sub-array");
@@ -606,7 +606,7 @@ function caml_ba_reshape(ba, vind) {
606606
new_dim[i] = vind[i];
607607
if (new_dim[i] < 0)
608608
caml_invalid_argument("Bigarray.reshape: negative dimension");
609-
num_elts = num_elts * new_dim[i];
609+
num_elts *= new_dim[i];
610610
}
611611

612612
const size = caml_ba_get_size(ba.dims);

runtime/blake2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ const blake2b = (() => {
120120
}
121121

122122
// low 64 bits of offset
123-
v[24] = v[24] ^ ctx.t;
124-
v[25] = v[25] ^ (ctx.t / 0x100000000);
123+
v[24] ^= ctx.t;
124+
v[25] ^= ctx.t / 0x100000000;
125125
// high 64 bits not supported, offset may not be higher than 2**53-1
126126

127127
// last block flag set ?

runtime/int64.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ MlInt64.prototype.xor = function (x) {
9696
return new MlInt64(this.lo ^ x.lo, this.mi ^ x.mi, this.hi ^ x.hi);
9797
};
9898
MlInt64.prototype.shift_left = function (s) {
99-
s = s & 63;
99+
s &= 63;
100100
if (s === 0) return this;
101101
if (s < 24) {
102102
return new MlInt64(
@@ -114,7 +114,7 @@ MlInt64.prototype.shift_left = function (s) {
114114
return new MlInt64(0, 0, this.lo << (s - 48));
115115
};
116116
MlInt64.prototype.shift_right_unsigned = function (s) {
117-
s = s & 63;
117+
s &= 63;
118118
if (s === 0) return this;
119119
if (s < 24)
120120
return new MlInt64(
@@ -131,7 +131,7 @@ MlInt64.prototype.shift_right_unsigned = function (s) {
131131
return new MlInt64(this.hi >> (s - 48), 0, 0);
132132
};
133133
MlInt64.prototype.shift_right = function (s) {
134-
s = s & 63;
134+
s &= 63;
135135
if (s === 0) return this;
136136
const h = (this.hi << 16) >> 16;
137137
if (s < 24)
@@ -157,7 +157,7 @@ MlInt64.prototype.lsl1 = function () {
157157
MlInt64.prototype.lsr1 = function () {
158158
this.lo = ((this.lo >>> 1) | (this.mi << 23)) & 0xffffff;
159159
this.mi = ((this.mi >>> 1) | (this.hi << 23)) & 0xffffff;
160-
this.hi = this.hi >>> 1;
160+
this.hi >>>= 1;
161161
};
162162
MlInt64.prototype.udivmod = function (x) {
163163
let offset = 0;

runtime/ints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function caml_int_of_string(s) {
121121
// For base different from 10, we expect an unsigned representation,
122122
// hence any value of 'res' (less than 'threshold') is acceptable.
123123
// But we have to convert the result back to a signed integer.
124-
res = sign * res;
124+
res *= sign;
125125
if (signedness && (res | 0) !== res)
126126
/* Signed representation expected, allow -2^(nbits-1) to 2^(nbits-1) - 1 */
127127
caml_failwith("int_of_string");

runtime/nat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function div_nat(nat1, ofs1, len1, nat2, ofs2, len2) {
366366
nat1.data[ofs1 + i] !== 0 ||
367367
compare_nat(nat1, ofs1 + i - len2, len2, nat2, ofs2, len2) >= 0
368368
) {
369-
quo = quo + 1;
369+
quo += 1;
370370
sub_nat(nat1, ofs1 + i - len2, len2 + 1, nat2, ofs2, len2, 1);
371371
}
372372

runtime/str.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ const re_match = (() => {
267267
case opcodes.ACCEPT:
268268
return accept();
269269
case opcodes.GOTO:
270-
pc = pc + sarg;
270+
pc += sarg;
271271
break;
272272
case opcodes.PUSHBACK:
273273
push({ pos: { pc: pc + sarg, txt: pos } });

0 commit comments

Comments
 (0)