Merge pull request #1254 from samitc/master

Improve performance of obj line break
pull/1258/head
Kim Kulling 2017-05-04 19:53:51 +02:00 committed by GitHub
commit 39e048dea6
1 changed files with 18 additions and 21 deletions

View File

@ -99,27 +99,24 @@ ObjFile::Model *ObjFileParser::GetModel() const {
} }
void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer) void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
{ {
std::vector<char> buf(buffer); auto curPosition = buffer.begin();
auto copyPosition = buffer.begin(); do
auto curPosition = buf.cbegin(); {
do while (*curPosition!='\n'&&*curPosition!='\\')
{ {
while (*curPosition != '\n'&&*curPosition != '\\') ++curPosition;
{ }
++curPosition; if (*curPosition=='\\')
} {
if (*curPosition == '\\') std::vector<char> tempBuf;
{ do
copyPosition = std::copy(buf.cbegin(), curPosition, copyPosition); {
*(copyPosition++) = ' '; streamBuffer.getNextLine(tempBuf);
do } while (tempBuf[0]=='\n');
{ *curPosition = ' ';
streamBuffer.getNextLine(buf); std::copy(tempBuf.cbegin(), tempBuf.cend(), ++curPosition);
} while (buf[0] == '\n'); }
curPosition = buf.cbegin(); } while (*curPosition!='\n');
}
} while (*curPosition != '\n');
std::copy(buf.cbegin(), curPosition, copyPosition);
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// File parsing method. // File parsing method.