Skip to content

Commit

Permalink
[Robustness] cache String slice
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 6, 2024
1 parent a24f5c5 commit 5ce0c56
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var $SyntaxError = require('es-errors/syntax');
var getGlobalSymbolDescription = GetIntrinsic('%Symbol.keyFor%', true);
var thisSymbolValue = callBound('%Symbol.prototype.valueOf%', true);
var symToStr = callBound('Symbol.prototype.toString', true);
var $strSlice = callBound('String.prototype.slice');

var getInferredName = require('./getInferredName');

Expand Down Expand Up @@ -36,7 +37,7 @@ module.exports = callBound('%Symbol.prototype.description%', true) || function g
}
}

desc = symToStr(sym).slice(7, -1); // str.slice('Symbol('.length, -')'.length);
desc = $strSlice(symToStr(sym), 7, -1); // str.slice('Symbol('.length, -')'.length);
if (desc) {
return desc;
}
Expand Down

0 comments on commit 5ce0c56

Please sign in to comment.