From 6e7c982ccb99cdea5760bfbf7318d5e14f332822 Mon Sep 17 00:00:00 2001 From: Valentin Semirulnik Date: Mon, 11 May 2026 03:19:00 +0400 Subject: [PATCH] perf: inline getArg(source) in generatedPositionFor --- lib/source-map-consumer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/source-map-consumer.js b/lib/source-map-consumer.js index e09b5b1b..f56ffcdb 100644 --- a/lib/source-map-consumer.js +++ b/lib/source-map-consumer.js @@ -1200,9 +1200,16 @@ BasicSourceMapConsumer.prototype.sourceContentFor = */ BasicSourceMapConsumer.prototype.generatedPositionFor = function SourceMapConsumer_generatedPositionFor(aArgs) { - var source = util.getArg(aArgs, 'source'); - source = this._findSourceIndex(source); + // Inline the `source` read — same megamorphic-call-site issue that hit + // the line/column reads in PR #72. The hot path is a single property + // access; the "is a required argument" throw is preserved but deferred + // to the slow path: if the lookup fails AND the key is absent, throw. + // Defined values (the hot path) never see the `in` check. + var source = this._findSourceIndex(aArgs.source); if (source < 0) { + if (!('source' in aArgs)) { + throw new Error('"source" is a required argument.'); + } return { line: null, column: null,