adding cache

pull/3068/head
yann300 2 years ago
parent 42fe88df86
commit 2b5f4eb9fe
  1. 13
      libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts
  2. 12
      libs/remix-debug/src/source/offsetToLineColumnConverter.ts

@ -13,9 +13,11 @@ const profile = {
export class OffsetToLineColumnConverter extends Plugin { export class OffsetToLineColumnConverter extends Plugin {
lineBreakPositionsByContent: Record<number, Array<number>> lineBreakPositionsByContent: Record<number, Array<number>>
sourceMappingDecoder: any sourceMappingDecoder: any
offsetConvertion: any
constructor () { constructor () {
super(profile) super(profile)
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.offsetConvertion = {}
this.sourceMappingDecoder = sourceMappingDecoder this.sourceMappingDecoder = sourceMappingDecoder
} }
@ -45,7 +47,15 @@ export class OffsetToLineColumnConverter extends Plugin {
} }
} }
} }
return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
const token = `${rawLocation.start}:${rawLocation.length}:${file}`
if (this.offsetConvertion[token]) {
return this.offsetConvertion[token]
} else {
const convertion = this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
this.offsetConvertion[token] = convertion
return convertion
}
} }
/** /**
@ -64,6 +74,7 @@ export class OffsetToLineColumnConverter extends Plugin {
*/ */
clear () { clear () {
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.offsetConvertion = {}
} }
/** /**

@ -4,9 +4,11 @@ import { getLinebreakPositions, convertOffsetToLineColumn } from './sourceMappin
export class OffsetToColumnConverter { export class OffsetToColumnConverter {
lineBreakPositionsByContent lineBreakPositionsByContent
sourceMappingDecoder sourceMappingDecoder
offsetConvertion
constructor (compilerEvent) { constructor (compilerEvent) {
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.offsetConvertion = {}
if (compilerEvent) { if (compilerEvent) {
compilerEvent.register('compilationFinished', (success, data, source, input, version) => { compilerEvent.register('compilationFinished', (success, data, source, input, version) => {
this.clear() this.clear()
@ -26,10 +28,18 @@ export class OffsetToColumnConverter {
} }
} }
} }
return convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) const token = `${rawLocation.start}:${rawLocation.length}:${file}`
if (this.offsetConvertion[token]) {
return this.offsetConvertion[token]
} else {
const convertion = convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file])
this.offsetConvertion[token] = convertion
return convertion
}
} }
clear () { clear () {
this.lineBreakPositionsByContent = {} this.lineBreakPositionsByContent = {}
this.offsetConvertion = {}
} }
} }

Loading…
Cancel
Save