let the background tokenizer give release the JS
thread more often
This commit is contained in:
parent
1d4c6fea49
commit
64aea4a8be
1 changed files with 7 additions and 9 deletions
|
|
@ -21,12 +21,12 @@ var BackgroundTokenizer = function(tokenizer) {
|
|||
self.lines[self.currentLine] = self.$tokenizeRow(self.currentLine);
|
||||
self.currentLine++;
|
||||
|
||||
// only check every 30 lines
|
||||
// only check every 5 lines
|
||||
processedLines += 1;
|
||||
if ((processedLines % 30 == 0) && (new Date() - workerStart) > 20) {
|
||||
//if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
|
||||
self.fireUpdateEvent(startLine, self.currentLine-1);
|
||||
return setTimeout(self.$worker, 10);
|
||||
}
|
||||
return setTimeout(self.$worker, 0);
|
||||
//}
|
||||
}
|
||||
|
||||
self.running = false;
|
||||
|
|
@ -67,11 +67,9 @@ var BackgroundTokenizer = function(tokenizer) {
|
|||
|
||||
this.lines.splice(this.currentLine, this.lines.length);
|
||||
|
||||
if (!this.running) {
|
||||
clearTimeout(this.running);
|
||||
// pretty long delay to prevent the tokenizer from interfering with the user
|
||||
this.running = setTimeout(this.$worker, 200);
|
||||
}
|
||||
this.stop();
|
||||
// pretty long delay to prevent the tokenizer from interfering with the user
|
||||
this.running = setTimeout(this.$worker, 200);
|
||||
};
|
||||
|
||||
this.stop = function() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue