Skip to content

Commit

Permalink
perf: small performance improvement for FileDiagnosticManager
Browse files Browse the repository at this point in the history
  • Loading branch information
armano2 authored and fi3ework committed Jun 29, 2024
1 parent 230095f commit 91d0cc2
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/vite-plugin-checker/src/FileDiagnosticManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ class FileDiagnosticManager {
throw new Error('FileDiagnosticManager is already initialized')
}

diagnostics.forEach((d) => {
this.diagnostics.push(d)
})

this.diagnostics = [...diagnostics]
this.initialized = true
}

Expand All @@ -28,12 +25,7 @@ class FileDiagnosticManager {
}

public updateByFileId(fileId: string, next: NormalizedDiagnostic[] | null) {
for (let i = 0; i < this.diagnostics.length; i++) {
if (this.diagnostics[i]?.id === fileId) {
this.diagnostics.splice(i, 1)
i--
}
}
this.diagnostics = this.diagnostics.filter((d) => d.id !== fileId)

if (next?.length) {
this.diagnostics.push(...next)
Expand Down

0 comments on commit 91d0cc2

Please sign in to comment.