提交 8fcfc7c2 编写于 作者: B Benjamin Pasero

limit the flood of progress events for fulltext searches

上级 c1eb759a
...@@ -22,6 +22,9 @@ interface ReadLinesOptions { ...@@ -22,6 +22,9 @@ interface ReadLinesOptions {
} }
export class Engine implements ISearchEngine { export class Engine implements ISearchEngine {
private static PROGRESS_FLUSH_CHUNK_SIZE = 50; // optimization: number of files to process before emitting progress event
private rootFolders: string[]; private rootFolders: string[];
private extraFiles: string[]; private extraFiles: string[];
private maxResults: number; private maxResults: number;
...@@ -62,7 +65,9 @@ export class Engine implements ISearchEngine { ...@@ -62,7 +65,9 @@ export class Engine implements ISearchEngine {
// Emit progress() unless we got canceled or hit the limit // Emit progress() unless we got canceled or hit the limit
if (processed && !this.isDone && !this.isCanceled && !this.limitReached) { if (processed && !this.isDone && !this.isCanceled && !this.limitReached) {
onProgress({ total: this.total, worked: this.worked }); if (this.worked % Engine.PROGRESS_FLUSH_CHUNK_SIZE === 0) {
onProgress({ total: this.total, worked: this.worked });
}
} }
// Emit done() // Emit done()
...@@ -82,7 +87,9 @@ export class Engine implements ISearchEngine { ...@@ -82,7 +87,9 @@ export class Engine implements ISearchEngine {
} }
// Indicate progress to the outside // Indicate progress to the outside
onProgress({ total: this.total, worked: this.worked }); if (this.worked % Engine.PROGRESS_FLUSH_CHUNK_SIZE === 0) {
onProgress({ total: this.total, worked: this.worked });
}
let fileMatch: FileMatch = null; let fileMatch: FileMatch = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册