From 52bc008efabe66147c4cd2293332a49e91f079df Mon Sep 17 00:00:00 2001 From: Peter Spiess-Knafl Date: Mon, 29 Oct 2018 23:30:59 +0100 Subject: [PATCH] Optimize delimiter checking in StreamReader (Closes #229) --- src/jsonrpccpp/common/streamreader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jsonrpccpp/common/streamreader.cpp b/src/jsonrpccpp/common/streamreader.cpp index a608858b..2de90261 100644 --- a/src/jsonrpccpp/common/streamreader.cpp +++ b/src/jsonrpccpp/common/streamreader.cpp @@ -1,5 +1,6 @@ #include "streamreader.h" #include +#include #include using namespace jsonrpc; @@ -19,7 +20,7 @@ bool StreamReader::Read(std::string &target, int fd, char delimiter) { } else { target.append(buffer, static_cast(bytesRead)); } - } while (target.find(delimiter) == string::npos && bytesRead > 0); + } while (memchr(buffer, delimiter, bytesRead) == NULL);//(target.find(delimiter) == string::npos && bytesRead > 0); target.pop_back(); return true;