Perf: compare and write file in worker

This commit is contained in:
SukkaW
2025-03-31 00:53:07 +08:00
parent 830ef80f7b
commit 8cefcf740c
4 changed files with 72 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import type { Span } from '../../trace';
import { compareAndWriteFile } from '../create-file';
import { compareAndWriteFileInWorker } from '../create-file.worker';
/**
* The class is not about holding rule data, instead it determines how the
@@ -76,6 +77,19 @@ export abstract class BaseWriteStrategy {
if (!this.result) {
return;
}
if (this.result.length > 1000) {
return compareAndWriteFileInWorker(
span,
this.withPadding(
title,
description,
date,
this.result
),
filePath
);
}
return compareAndWriteFile(
span,
this.withPadding(