summaryrefslogtreecommitdiff
path: root/lib/assert.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-05-01 23:54:02 +0200
committerRich Trott <rtrott@gmail.com>2019-05-05 14:44:21 -0700
commitd099f2f1248204585adf9965204b6efe1ad92b80 (patch)
treee73a9055a194cbcee4e30f42e95ca6d2eec8f0bf /lib/assert.js
parent0cd602879c5e3f6a77adc2453f98b331421b2dbb (diff)
downloadandroid-node-v8-d099f2f1248204585adf9965204b6efe1ad92b80.tar.gz
android-node-v8-d099f2f1248204585adf9965204b6efe1ad92b80.tar.bz2
android-node-v8-d099f2f1248204585adf9965204b6efe1ad92b80.zip
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: https://github.com/nodejs/node/pull/27525 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'lib/assert.js')
-rw-r--r--lib/assert.js9
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/assert.js b/lib/assert.js
index dece9a08a7..6e0b850b40 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -172,8 +172,8 @@ function getCode(fd, line, column) {
let lines = 0;
// Prevent blocking the event loop by limiting the maximum amount of
// data that may be read.
- let maxReads = 64; // bytesPerRead * maxReads = 512 kb
- const bytesPerRead = 8192;
+ let maxReads = 32; // bytesPerRead * maxReads = 512 kb
+ const bytesPerRead = 16384;
// Use a single buffer up front that is reused until the call site is found.
let buffer = Buffer.allocUnsafe(bytesPerRead);
while (maxReads-- !== 0) {
@@ -619,11 +619,6 @@ function checkIsPromise(obj) {
// Accept native ES6 promises and promises that are implemented in a similar
// way. Do not accept thenables that use a function as `obj` and that have no
// `catch` handler.
-
- // TODO: thenables are checked up until they have the correct methods,
- // but according to documentation, the `then` method should receive
- // the `fulfill` and `reject` arguments as well or it may be never resolved.
-
return isPromise(obj) ||
obj !== null && typeof obj === 'object' &&
typeof obj.then === 'function' &&