stream: remove duplicated expression
authorYazhong Liu <yorkiefixer@gmail.com>
Thu, 2 Oct 2014 16:00:40 +0000 (00:00 +0800)
committerJeremiah Senkpiel <fishrock123@rocketmail.com>
Thu, 16 Apr 2015 23:26:11 +0000 (19:26 -0400)
PR-URL: https://github.com/iojs/io.js/pull/1444
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
lib/_stream_readable.js

index 5600218..1de5559 100644 (file)
@@ -125,8 +125,7 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
     stream.emit('error', er);
   } else if (chunk === null) {
     state.reading = false;
-    if (!state.ended)
-      onEofChunk(stream, state);
+    onEofChunk(stream, state);
   } else if (state.objectMode || chunk && chunk.length > 0) {
     if (state.ended && !addToFront) {
       var e = new Error('stream.push() after EOF');
@@ -372,7 +371,8 @@ function chunkInvalid(state, chunk) {
 
 
 function onEofChunk(stream, state) {
-  if (state.decoder && !state.ended) {
+  if (state.ended) return;
+  if (state.decoder) {
     var chunk = state.decoder.end();
     if (chunk && chunk.length) {
       state.buffer.push(chunk);