Fix find newline looping to have additional break early cases (#4614)
This commit is contained in:
@@ -376,10 +376,15 @@ static size_t NextLineLength(const std::string* textStr, const size_t lastNewlin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
||||
size_t newLine = str.find(NEWLINE()[0], lastNewline);
|
||||
bool done;
|
||||
|
||||
// Bail out early
|
||||
if (newLine == std::string::npos) {
|
||||
return newLine;
|
||||
}
|
||||
|
||||
do {
|
||||
done = true;
|
||||
if (newLine != 0) {
|
||||
@@ -420,12 +425,13 @@ size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
|
||||
}
|
||||
if (!done) {
|
||||
newLine = str.find(NEWLINE()[0], newLine + 1);
|
||||
if (newLine != std::string::npos){
|
||||
if (newLine == std::string::npos) {
|
||||
// if we reach the end of the string, quit now to save a loop
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
return newLine;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user