url: fix permanent deoptimizations
PR-URL: https://github.com/nodejs/node/pull/12456 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
a641b7cf3e
commit
8491c705b1
@ -232,9 +232,9 @@ class URL {
|
|||||||
if (typeof depth === 'number' && depth < 0)
|
if (typeof depth === 'number' && depth < 0)
|
||||||
return opts.stylize('[Object]', 'special');
|
return opts.stylize('[Object]', 'special');
|
||||||
|
|
||||||
const ctor = getConstructorOf(this);
|
var ctor = getConstructorOf(this);
|
||||||
|
|
||||||
const obj = Object.create({
|
var obj = Object.create({
|
||||||
constructor: ctor === null ? URL : ctor
|
constructor: ctor === null ? URL : ctor
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -879,20 +879,20 @@ class URLSearchParams {
|
|||||||
if (typeof recurseTimes === 'number' && recurseTimes < 0)
|
if (typeof recurseTimes === 'number' && recurseTimes < 0)
|
||||||
return ctx.stylize('[Object]', 'special');
|
return ctx.stylize('[Object]', 'special');
|
||||||
|
|
||||||
const separator = ', ';
|
var separator = ', ';
|
||||||
const innerOpts = Object.assign({}, ctx);
|
var innerOpts = Object.assign({}, ctx);
|
||||||
if (recurseTimes !== null) {
|
if (recurseTimes !== null) {
|
||||||
innerOpts.depth = recurseTimes - 1;
|
innerOpts.depth = recurseTimes - 1;
|
||||||
}
|
}
|
||||||
const innerInspect = (v) => util.inspect(v, innerOpts);
|
var innerInspect = (v) => util.inspect(v, innerOpts);
|
||||||
|
|
||||||
const list = this[searchParams];
|
var list = this[searchParams];
|
||||||
const output = [];
|
var output = [];
|
||||||
for (var i = 0; i < list.length; i += 2)
|
for (var i = 0; i < list.length; i += 2)
|
||||||
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);
|
output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`);
|
||||||
|
|
||||||
const colorRe = /\u001b\[\d\d?m/g;
|
var colorRe = /\u001b\[\d\d?m/g;
|
||||||
const length = output.reduce(
|
var length = output.reduce(
|
||||||
(prev, cur) => prev + cur.replace(colorRe, '').length + separator.length,
|
(prev, cur) => prev + cur.replace(colorRe, '').length + separator.length,
|
||||||
-separator.length
|
-separator.length
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user