diff --git a/benchmark/util/inspect.js b/benchmark/util/inspect.js index 8e453b9e226e..23beac0039b2 100644 --- a/benchmark/util/inspect.js +++ b/benchmark/util/inspect.js @@ -14,6 +14,7 @@ const bench = common.createBenchmark(main, { 'Object', 'Object_empty', 'Object_deep_ln', + 'Object_large', 'String', 'String_complex', 'String_boxed', @@ -61,6 +62,13 @@ function main({ method, n, option }) { g: 'seventh' } } } }; benchmark(n, obj, options || { depth: Infinity }); break; + case 'Object_large': + obj = {}; + for (let i = 0; i < 50; i++) { + obj[`key${i}`] = i; + } + benchmark(n, obj, options); + break; case 'String': benchmark(n, 'Simple string', options); break; diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 7ee103196585..26cf23bf0fa3 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -1434,14 +1434,12 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { const tempValue = { [extraKeys[i]]: value.buffer[extraKeys[i]] }; formatted = formatExtraProperties(ctx, tempValue, recurseTimes, extraKeys[i], typedArray); } - ArrayPrototypePush(output, formatted); + output[output.length] = formatted; } } for (i = 0; i < keys.length; i++) { - ArrayPrototypePush( - output, - formatProperty(ctx, value, recurseTimes, keys[i], extrasType), - ); + output[output.length] = + formatProperty(ctx, value, recurseTimes, keys[i], extrasType); } if (protoProps !== undefined) { ArrayPrototypePushApply(output, protoProps);