[clang-tools-extra] r329958 - [clangd][nfc] Simplify readDelimitedMessage()
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 12 14:33:24 PDT 2018
Author: jkorous
Date: Thu Apr 12 14:33:24 2018
New Revision: 329958
URL: http://llvm.org/viewvc/llvm-project?rev=329958&view=rev
Log:
[clangd][nfc] Simplify readDelimitedMessage()
istream::eof() is always false after successful getline()
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=329958&r1=329957&r2=329958&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Thu Apr 12 14:33:24 2018
@@ -271,8 +271,8 @@ static llvm::Optional<std::string> readD
std::string JSON;
std::string Line;
while (std::getline(In, Line)) {
- if (!In.eof()) // getline() consumed the newline.
- Line.push_back('\n');
+ Line.push_back('\n'); // getline() consumed the newline.
+
auto LineRef = llvm::StringRef(Line).trim();
if (LineRef.startswith("#")) // comment
continue;
@@ -280,7 +280,7 @@ static llvm::Optional<std::string> readD
bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos;
if (!IsDelim) // Line is part of a JSON message.
JSON += Line;
- if (IsDelim || In.eof()) {
+ if (IsDelim) {
Out.mirrorInput(
llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON));
return std::move(JSON);
More information about the cfe-commits
mailing list