From 3f7a86490c72bc2e5d343b5a201e379a4e2a5cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A5=BC=E6=95=99=E4=B8=BB?= Date: Wed, 27 Jan 2016 23:07:07 +0800 Subject: [PATCH] Ignore \r character alone, in order to improve performance. --- readline.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readline.js b/readline.js index 2783c64..345d615 100644 --- a/readline.js +++ b/readline.js @@ -32,11 +32,11 @@ var readLine = module.exports = function(file, opts) { .on('data', function onData(data) { var dataLen = data.length; for (var i = 0; i < dataLen; i++) { - if (data[i] == 10 || data[i] == 13) { // Newline char was found. - if (data[i] == 10) { - lineCount++; - emit(lineCount, byteCount); - } + if (data[i] === 10) { // Newline char was found. + lineCount++; + emit(lineCount, byteCount); + } else if (data[i] === 13) { + // ignore } else { lineBuffer[lineLength] = data[i]; // Buffer new line data. lineLength++;