diff --git a/lib/base/stream.cpp b/lib/base/stream.cpp index 3048f096c..0b847060f 100644 --- a/lib/base/stream.cpp +++ b/lib/base/stream.cpp @@ -129,31 +129,19 @@ StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool } } - int count = 0; - size_t first_newline; - for (size_t i = 0; i < context.Size; i++) { if (context.Buffer[i] == '\n') { - count++; + *line = String(context.Buffer, context.Buffer + i); + boost::algorithm::trim_right(*line); - if (count == 1) - first_newline = i; - else if (count > 1) - break; + context.DropData(i + 1u); + + context.MustRead = !context.Size; + return StatusNewItem; } } - context.MustRead = (count <= 1); - - if (count > 0) { - *line = String(context.Buffer, &(context.Buffer[first_newline])); - boost::algorithm::trim_right(*line); - - context.DropData(first_newline + 1); - - return StatusNewItem; - } - + context.MustRead = true; return StatusNeedData; }