optimize loc for monomorphic inline caching

This commit is contained in:
ShobhitPatra 2025-03-13 20:21:25 +05:30
parent cb25853b58
commit 394c4c32e9
1 changed files with 11 additions and 7 deletions

View File

@ -132,19 +132,23 @@ class Dependency {
get loc() { get loc() {
if (this._loc !== undefined) return this._loc; if (this._loc !== undefined) return this._loc;
/** @type {SyntheticDependencyLocation & RealDependencyLocation} */ /** @type {SyntheticDependencyLocation & RealDependencyLocation} */
const loc = {}; const loc = {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 },
name: "",
index: -1
};
if (this._locSL > 0) { if (this._locSL > 0) {
loc.start = { line: this._locSL, column: this._locSC }; loc.start = { line: this._locSL, column: this._locSC };
} }
if (this._locEL > 0) { if (this._locEL > 0) {
loc.end = { line: this._locEL, column: this._locEC }; loc.end = { line: this._locEL, column: this._locEC };
} }
if (this._locN !== undefined) {
loc.name = this._locN; loc.name = this._locN;
}
if (this._locI !== undefined) { loc.index = this._locI;
loc.index = this._locI;
}
return (this._loc = loc); return (this._loc = loc);
} }