Skip to content

Commit

Permalink
avoid unneeded call indirection
Browse files Browse the repository at this point in the history
  • Loading branch information
eladkishon committed Apr 6, 2021
1 parent 54c6e38 commit 36082c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 0 additions & 6 deletions lib/internal/errors.js
Expand Up @@ -428,11 +428,6 @@ function uvErrmapGet(name) {
return MapPrototypeGet(uvBinding.errmap, name);
}

function uvGetFullErrMap() {
uvBinding = lazyUv();
return uvBinding.getErrorMap();
}

const captureLargerStackTrace = hideStackFrames(
function captureLargerStackTrace(err) {
userStackTraceLimit = Error.stackTraceLimit;
Expand Down Expand Up @@ -787,7 +782,6 @@ module.exports = {
isStackOverflowError,
connResetException,
uvErrmapGet,
uvGetFullErrMap,
uvException,
uvExceptionWithHostPort,
SystemError,
Expand Down
14 changes: 12 additions & 2 deletions lib/internal/util.js
Expand Up @@ -35,7 +35,6 @@ const {
ERR_UNKNOWN_SIGNAL
},
uvErrmapGet,
uvGetFullErrMap,
overrideStackTrace,
} = require('internal/errors');
const { signals } = internalBinding('constants').os;
Expand All @@ -54,6 +53,16 @@ const experimentalWarnings = new SafeSet();

const colorRegExp = /\u001b\[\d\d?m/g; // eslint-disable-line no-control-regex


let uvBinding;

function lazyUv() {
if (!uvBinding) {
uvBinding = internalBinding('uv');
}
return uvBinding;
}

function removeColors(str) {
return StringPrototypeReplace(str, colorRegExp, '');
}
Expand Down Expand Up @@ -288,7 +297,8 @@ function getSystemErrorName(err) {
}

function getSystemErrorMap() {
return uvGetFullErrMap();
uvBinding = lazyUv();
return uvBinding.getErrorMap();
}

const kCustomPromisifiedSymbol = SymbolFor('nodejs.util.promisify.custom');
Expand Down
6 changes: 1 addition & 5 deletions lib/util.js
Expand Up @@ -68,7 +68,7 @@ const types = require('internal/util/types');
const {
deprecate,
getSystemErrorName: internalErrorName,
getSystemErrorMap: internalErrorMap,
getSystemErrorMap,
promisify
} = require('internal/util');

Expand Down Expand Up @@ -245,10 +245,6 @@ function getSystemErrorName(err) {
}
return internalErrorName(err);
}

function getSystemErrorMap() {
return internalErrorMap();
}
// Keep the `exports =` so that various functions can still be monkeypatched
module.exports = {
_errnoException: errnoException,
Expand Down

0 comments on commit 36082c2

Please sign in to comment.