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 <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 3367bad commit ec642f1

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎lib/assert.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ function getCode(fd, line, column) {
172172
letlines=0;
173173
// Prevent blocking the event loop by limiting the maximum amount of
174174
// data that may be read.
175-
letmaxReads=64;// bytesPerRead * maxReads = 512 kb
176-
constbytesPerRead=8192;
175+
letmaxReads=32;// bytesPerRead * maxReads = 512 kb
176+
constbytesPerRead=16384;
177177
// Use a single buffer up front that is reused until the call site is found.
178178
letbuffer=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
returnisPromise(obj)||
628623
obj!==null&&typeofobj==='object'&&
629624
typeofobj.then==='function'&&

0 commit comments

Comments
 (0)