Skip to content

Commit ec642f1

Browse files
BridgeARtargos
authored andcommitted
assert: use less read operations
This reduces the total amount of reads when using `assert.ok()` with a falsy value. That increases the read performance significantly. Also remove a comment that can not be addressed. PR-URL: #27525 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 3367bad commit ec642f1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/assert.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ function getCode(fd, line, column) {
172172
let lines = 0;
173173
// Prevent blocking the event loop by limiting the maximum amount of
174174
// data that may be read.
175-
let maxReads = 64; // bytesPerRead * maxReads = 512 kb
176-
const bytesPerRead = 8192;
175+
let maxReads = 32; // bytesPerRead * maxReads = 512 kb
176+
const bytesPerRead = 16384;
177177
// Use a single buffer up front that is reused until the call site is found.
178178
let buffer = Buffer.allocUnsafe(bytesPerRead);
179179
while (maxReads-- !== 0) {
@@ -619,11 +619,6 @@ function checkIsPromise(obj) {
619619
// Accept native ES6 promises and promises that are implemented in a similar
620620
// way. Do not accept thenables that use a function as `obj` and that have no
621621
// `catch` handler.
622-
623-
// TODO: thenables are checked up until they have the correct methods,
624-
// but according to documentation, the `then` method should receive
625-
// the `fulfill` and `reject` arguments as well or it may be never resolved.
626-
627622
return isPromise(obj) ||
628623
obj !== null && typeof obj === 'object' &&
629624
typeof obj.then === 'function' &&

0 commit comments

Comments
 (0)