diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index ea32f43e..e09b5b1b 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -966,14 +966,22 @@ BasicSourceMapConsumer.prototype.computeColumnSpans = */ BasicSourceMapConsumer.prototype.originalPositionFor = function SourceMapConsumer_originalPositionFor(aArgs) { - var needleLine = util.getArg(aArgs, 'line'); - var needleColumn = util.getArg(aArgs, 'column'); - // The legacy code path went through `_findMapping` which validated - // line/column at the entry. Slab-direct lookups bypass that, so - // we have to validate explicitly to keep the documented errors. + // Inline the optional read for required args — every trace call paid + // for a `getArg` function call plus an `'in' in aArgs` check. Combining + // the value validation with a `typeof !== 'number'` guard preserves the + // documented "is a required argument" error for missing/undefined args + // while skipping the function-call overhead. + var needleLine = aArgs.line; + var needleColumn = aArgs.column; + if (typeof needleLine !== 'number') { + throw new Error('"line" is a required argument.'); + } if (needleLine <= 0) { throw new TypeError('Line must be greater than or equal to 1, got ' + needleLine); } + if (typeof needleColumn !== 'number') { + throw new Error('"column" is a required argument.'); + } if (needleColumn < 0) { throw new TypeError('Column must be greater than or equal to 0, got ' + needleColumn); } @@ -1202,11 +1210,18 @@ BasicSourceMapConsumer.prototype.generatedPositionFor = }; } - var needleLine = util.getArg(aArgs, 'line'); - var needleColumn = util.getArg(aArgs, 'column'); + // Inline the required-arg reads — same pattern as originalPositionFor. + var needleLine = aArgs.line; + var needleColumn = aArgs.column; + if (typeof needleLine !== 'number') { + throw new Error('"line" is a required argument.'); + } if (needleLine <= 0) { throw new TypeError('Line must be greater than or equal to 1, got ' + needleLine); } + if (typeof needleColumn !== 'number') { + throw new Error('"column" is a required argument.'); + } if (needleColumn < 0) { throw new TypeError('Column must be greater than or equal to 0, got ' + needleColumn); }