mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
readline: fix performance issue when large line
Only run lineEnding.test() on the newly acquired chunk of string instead of on the entire line buffer. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
1 parent
51b6b6844e
commit
f3473d7db6
1 file changed
+4
-1
+4
-1
@@ -310,11 +310,14 @@ Interface.prototype._normalWrite = function(b) {
|
||||
this._sawReturn = false;
|
||||
}
|
||||
|
||||
// Run test() on the new string chunk, not on the entire line buffer.
|
||||
var newPartContainsEnding = lineEnding.test(string);
|
||||
|
||||
if (this._line_buffer) {
|
||||
string = this._line_buffer + string;
|
||||
this._line_buffer = null;
|
||||
}
|
||||
if (lineEnding.test(string)) {
|
||||
if (newPartContainsEnding) {
|
||||
this._sawReturn = /\r$/.test(string);
|
||||
|
||||
// got one or more newlines; process into "line" events
|
||||
|
||||
Reference in new issue
Block a user