Improve performance of obj line break

pull/1254/head
Amit Cirt 2017-05-01 16:32:49 +03:00
parent 3f361ecc1f
commit 8b4e066ca5
1 changed files with 18 additions and 21 deletions

View File

@ -99,9 +99,8 @@ 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); static std::vector<char> tempBuf;
auto copyPosition = buffer.begin(); auto curPosition = buffer.begin();
auto curPosition = buf.cbegin();
do do
{ {
while (*curPosition!='\n'&&*curPosition!='\\') while (*curPosition!='\n'&&*curPosition!='\\')
@ -110,16 +109,14 @@ void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffe
} }
if (*curPosition=='\\') if (*curPosition=='\\')
{ {
copyPosition = std::copy(buf.cbegin(), curPosition, copyPosition);
*(copyPosition++) = ' ';
do do
{ {
streamBuffer.getNextLine(buf); streamBuffer.getNextLine(tempBuf);
} while (buf[0] == '\n'); } while (tempBuf[0]=='\n');
curPosition = buf.cbegin(); *curPosition = ' ';
std::copy(tempBuf.cbegin(), tempBuf.cend(), ++curPosition);
} }
} while (*curPosition!='\n'); } while (*curPosition!='\n');
std::copy(buf.cbegin(), curPosition, copyPosition);
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// File parsing method. // File parsing method.