mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Some perf tweaks
This commit is contained in:
parent
76a920c169
commit
b795358075
|
@ -41,4 +41,7 @@ function code() {
|
|||
exec "$CODE" . "$@"
|
||||
}
|
||||
|
||||
# Use the following to get v8 tracing:
|
||||
# code --js-flags="--trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces" "$@"
|
||||
|
||||
code "$@"
|
||||
|
|
|
@ -713,12 +713,14 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
|
|||
}
|
||||
|
||||
let markers = line.getMarkers();
|
||||
for (let j = 0, lenJ = markers.length; j < lenJ; j++) {
|
||||
foundMarkersCnt++;
|
||||
let markerId = markers[j].id;
|
||||
let marker = this._markerIdToMarker[markerId];
|
||||
if (marker.position.lineNumber !== line.lineNumber) {
|
||||
throw new Error('Misplaced marker with id ' + markerId);
|
||||
if (markers !== null) {
|
||||
for (let j = 0, lenJ = markers.length; j < lenJ; j++) {
|
||||
foundMarkersCnt++;
|
||||
let markerId = markers[j].id;
|
||||
let marker = this._markerIdToMarker[markerId];
|
||||
if (marker.position.lineNumber !== line.lineNumber) {
|
||||
throw new Error('Misplaced marker with id ' + markerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -721,9 +721,9 @@ export class ModelLine {
|
|||
|
||||
public getMarkers(): LineMarker[] {
|
||||
if (!this._markers) {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
return this._markers.slice(0);
|
||||
return this._markers;
|
||||
}
|
||||
|
||||
public updateLineNumber(markersTracker: MarkersTracker, newLineNumber: number): void {
|
||||
|
|
|
@ -347,7 +347,10 @@ export class TextModelWithDecorations extends TextModelWithMarkers implements ed
|
|||
}
|
||||
|
||||
for (let lineNumber = filterStartLineNumber; lineNumber <= filterEndLineNumber; lineNumber++) {
|
||||
let lineMarkers = this._getLineMarkers(lineNumber);
|
||||
let lineMarkers = this._lines[lineNumber - 1].getMarkers();
|
||||
if (lineMarkers === null) {
|
||||
continue;
|
||||
}
|
||||
for (let i = 0, len = lineMarkers.length; i < len; i++) {
|
||||
let lineMarker = lineMarkers[i];
|
||||
let internalDecorationId = lineMarker.internalDecorationId;
|
||||
|
|
|
@ -137,14 +137,6 @@ export class TextModelWithMarkers extends TextModelWithTokens implements ITextMo
|
|||
return Object.keys(this._markerIdToMarker).length;
|
||||
}
|
||||
|
||||
protected _getLineMarkers(lineNumber: number): LineMarker[] {
|
||||
if (lineNumber < 1 || lineNumber > this.getLineCount()) {
|
||||
throw new Error('Illegal value ' + lineNumber + ' for `lineNumber`');
|
||||
}
|
||||
|
||||
return this._lines[lineNumber - 1].getMarkers();
|
||||
}
|
||||
|
||||
_removeMarker(id: string): void {
|
||||
let marker = this._markerIdToMarker[id];
|
||||
if (!marker) {
|
||||
|
|
|
@ -33,12 +33,13 @@ export class PrefixSumComputer {
|
|||
/**
|
||||
* prefixSum[i], 0 <= i <= prefixSumValidIndex can be trusted
|
||||
*/
|
||||
private prefixSumValidIndex: number;
|
||||
private prefixSumValidIndex: Int32Array;
|
||||
|
||||
constructor(values: Uint32Array) {
|
||||
this.values = values;
|
||||
this.prefixSum = new Uint32Array(values.length);
|
||||
this.prefixSumValidIndex = -1;
|
||||
this.prefixSumValidIndex = new Int32Array(1);
|
||||
this.prefixSumValidIndex[0] = -1;
|
||||
}
|
||||
|
||||
public getCount(): number {
|
||||
|
@ -60,13 +61,13 @@ export class PrefixSumComputer {
|
|||
this.values.set(oldValues.subarray(insertIndex), insertIndex + insertValuesLen);
|
||||
this.values.set(insertValues, insertIndex);
|
||||
|
||||
if (insertIndex - 1 < this.prefixSumValidIndex) {
|
||||
this.prefixSumValidIndex = insertIndex - 1;
|
||||
if (insertIndex - 1 < this.prefixSumValidIndex[0]) {
|
||||
this.prefixSumValidIndex[0] = insertIndex - 1;
|
||||
}
|
||||
|
||||
this.prefixSum = new Uint32Array(this.values.length);
|
||||
if (this.prefixSumValidIndex >= 0) {
|
||||
this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex + 1));
|
||||
if (this.prefixSumValidIndex[0] >= 0) {
|
||||
this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,8 +79,8 @@ export class PrefixSumComputer {
|
|||
return;
|
||||
}
|
||||
this.values[index] = value;
|
||||
if (index - 1 < this.prefixSumValidIndex) {
|
||||
this.prefixSumValidIndex = index - 1;
|
||||
if (index - 1 < this.prefixSumValidIndex[0]) {
|
||||
this.prefixSumValidIndex[0] = index - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,11 +109,11 @@ export class PrefixSumComputer {
|
|||
this.values.set(oldValues.subarray(startIndex + cnt), startIndex);
|
||||
|
||||
this.prefixSum = new Uint32Array(this.values.length);
|
||||
if (startIndex - 1 < this.prefixSumValidIndex) {
|
||||
this.prefixSumValidIndex = startIndex - 1;
|
||||
if (startIndex - 1 < this.prefixSumValidIndex[0]) {
|
||||
this.prefixSumValidIndex[0] = startIndex - 1;
|
||||
}
|
||||
if (this.prefixSumValidIndex >= 0) {
|
||||
this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex + 1));
|
||||
if (this.prefixSumValidIndex[0] >= 0) {
|
||||
this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,11 +131,11 @@ export class PrefixSumComputer {
|
|||
|
||||
index = toUint32(index);
|
||||
|
||||
if (index <= this.prefixSumValidIndex) {
|
||||
if (index <= this.prefixSumValidIndex[0]) {
|
||||
return this.prefixSum[index];
|
||||
}
|
||||
|
||||
let startIndex = this.prefixSumValidIndex + 1;
|
||||
let startIndex = this.prefixSumValidIndex[0] + 1;
|
||||
if (startIndex === 0) {
|
||||
this.prefixSum[0] = this.values[0];
|
||||
startIndex++;
|
||||
|
@ -147,7 +148,7 @@ export class PrefixSumComputer {
|
|||
for (let i = startIndex; i <= index; i++) {
|
||||
this.prefixSum[i] = this.prefixSum[i - 1] + this.values[i];
|
||||
}
|
||||
this.prefixSumValidIndex = Math.max(this.prefixSumValidIndex, index);
|
||||
this.prefixSumValidIndex[0] = Math.max(this.prefixSumValidIndex[0], index);
|
||||
return this.prefixSum[index];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue