mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
chore(core,ext): minor JS optimisations (#13950)
This commit is contained in:
parent
3f7d2fc1e9
commit
9f20c312c1
3 changed files with 14 additions and 13 deletions
|
@ -27,7 +27,10 @@
|
||||||
SymbolFor,
|
SymbolFor,
|
||||||
} = window.__bootstrap.primordials;
|
} = window.__bootstrap.primordials;
|
||||||
const ops = window.Deno.core.ops;
|
const ops = window.Deno.core.ops;
|
||||||
const opIds = Object.keys(ops).reduce((a, v, i) => ({ ...a, [v]: i }), {});
|
const opIds = Object.keys(ops).reduce((a, v, i) => {
|
||||||
|
a[v] = i;
|
||||||
|
return a;
|
||||||
|
}, {});
|
||||||
|
|
||||||
// Available on start due to bindings.
|
// Available on start due to bindings.
|
||||||
const { refOp_, unrefOp_ } = window.Deno.core;
|
const { refOp_, unrefOp_ } = window.Deno.core;
|
||||||
|
|
|
@ -279,9 +279,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
send(p, addr) {
|
send(p, addr) {
|
||||||
const remote = { hostname: "127.0.0.1", ...addr };
|
const args = { hostname: "127.0.0.1", ...addr, rid: this.rid };
|
||||||
|
|
||||||
const args = { ...remote, rid: this.rid };
|
|
||||||
return opSend(args, p);
|
return opSend(args, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@
|
||||||
const twoToOneLessThanTheBitLength = MathPow(2, bitLength - 1);
|
const twoToOneLessThanTheBitLength = MathPow(2, bitLength - 1);
|
||||||
|
|
||||||
return (V, opts = {}) => {
|
return (V, opts = {}) => {
|
||||||
let x = toNumber(V, opts);
|
let x = toNumber(V);
|
||||||
x = censorNegativeZero(x);
|
x = censorNegativeZero(x);
|
||||||
|
|
||||||
if (opts.enforceRange) {
|
if (opts.enforceRange) {
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
const asBigIntN = unsigned ? BigIntAsUintN : BigIntAsIntN;
|
const asBigIntN = unsigned ? BigIntAsUintN : BigIntAsIntN;
|
||||||
|
|
||||||
return (V, opts = {}) => {
|
return (V, opts = {}) => {
|
||||||
let x = toNumber(V, opts);
|
let x = toNumber(V);
|
||||||
x = censorNegativeZero(x);
|
x = censorNegativeZero(x);
|
||||||
|
|
||||||
if (opts.enforceRange) {
|
if (opts.enforceRange) {
|
||||||
|
@ -300,7 +300,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
converters.float = (V, opts) => {
|
converters.float = (V, opts) => {
|
||||||
const x = toNumber(V, opts);
|
const x = toNumber(V);
|
||||||
|
|
||||||
if (!NumberIsFinite(x)) {
|
if (!NumberIsFinite(x)) {
|
||||||
throw makeException(
|
throw makeException(
|
||||||
|
@ -327,8 +327,8 @@
|
||||||
return y;
|
return y;
|
||||||
};
|
};
|
||||||
|
|
||||||
converters["unrestricted float"] = (V, opts) => {
|
converters["unrestricted float"] = (V, _opts) => {
|
||||||
const x = toNumber(V, opts);
|
const x = toNumber(V);
|
||||||
|
|
||||||
if (isNaN(x)) {
|
if (isNaN(x)) {
|
||||||
return x;
|
return x;
|
||||||
|
@ -342,7 +342,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
converters.double = (V, opts) => {
|
converters.double = (V, opts) => {
|
||||||
const x = toNumber(V, opts);
|
const x = toNumber(V);
|
||||||
|
|
||||||
if (!NumberIsFinite(x)) {
|
if (!NumberIsFinite(x)) {
|
||||||
throw makeException(
|
throw makeException(
|
||||||
|
@ -355,8 +355,8 @@
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
converters["unrestricted double"] = (V, opts) => {
|
converters["unrestricted double"] = (V, _opts) => {
|
||||||
const x = toNumber(V, opts);
|
const x = toNumber(V);
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
@ -714,7 +714,7 @@
|
||||||
throw makeException(
|
throw makeException(
|
||||||
TypeError,
|
TypeError,
|
||||||
`can not be converted to '${name}' because '${key}' is required in '${name}'.`,
|
`can not be converted to '${name}' because '${key}' is required in '${name}'.`,
|
||||||
{ ...opts },
|
opts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue