Skip to content

Commit

Permalink
Optimize delimiter checking in StreamReader (Closes #229)
Browse files Browse the repository at this point in the history
  • Loading branch information
cinemast committed Oct 29, 2018
1 parent ae1a76f commit 52bc008
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/jsonrpccpp/common/streamreader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "streamreader.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

using namespace jsonrpc;
Expand All @@ -19,7 +20,7 @@ bool StreamReader::Read(std::string &target, int fd, char delimiter) {
} else {
target.append(buffer, static_cast<size_t>(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;
Expand Down

0 comments on commit 52bc008

Please sign in to comment.