Commit 5df601d9 authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Tomaz Canabrava
Browse files

Avoid moving memory around in copyLineToStream

If the "Trim leading spaces" option is set, we can pass a pointer to the
first non-space character to decodeLine(), no need to first move memory
around.
parent b11f6533
......@@ -1634,8 +1634,8 @@ int Screen::copyLineToStream(int line,
}
}
int spacesCount = 0;
if ((options & TrimLeadingWhitespace) != 0U) {
int spacesCount = 0;
for (spacesCount = 0; spacesCount < count; ++spacesCount) {
if (QChar::category(characterBuffer[spacesCount].character) != QChar::Category::Separator_Space) {
break;
......@@ -1646,13 +1646,11 @@ int Screen::copyLineToStream(int line,
return 0;
}
std::copy(characterBuffer + spacesCount, characterBuffer + count, characterBuffer);
count -= spacesCount;
}
// decode line and write to text stream
decoder->decodeLine(characterBuffer, count, currentLineProperties);
decoder->decodeLine(characterBuffer + spacesCount, count, currentLineProperties);
return count;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment