Commit 62ffda33 authored by Carlos Alves's avatar Carlos Alves Committed by Kurt Hindenburg
Browse files

Small change do STL

Where it was possible:
- 'For' to STL copy or fill (it is like using memcpy and memset, faster
than for, the compiler decides the best algo to perform the task);
- 'For' + 'if' to 'where', it is faster and cleanner to read.

Changes in: PlainTextDecoder.cpp, HTMLDecoder.cpp, ColorScheme.cpp and
ExtendedCharTable.cpp
parent 8c57c842
......@@ -74,9 +74,7 @@ uint ExtendedCharTable::createExtendedChar(const uint *unicodePoints, ushort len
// return that index
auto buffer = new uint[length + 1];
buffer[0] = length;
for (int i = 0; i < length; i++) {
buffer[i + 1] = unicodePoints[i];
}
std::copy_n(unicodePoints, length, &buffer[1]);
_extendedCharTable.insert(hash, buffer);
......
......@@ -232,9 +232,7 @@ void ColorScheme::setColorTableEntry(int index, const QColor &entry)
if (_table == nullptr) {
_table = new QColor[TABLE_COLORS];
for (int i = 0; i < TABLE_COLORS; i++) {
_table[i] = defaultTable[i];
}
std::copy_n(defaultTable, TABLE_COLORS, _table);
}
if (entry.isValid()) {
......
......@@ -44,9 +44,7 @@ HTMLDecoder::HTMLDecoder(const QString &colorSchemeName, const QFont &profileFon
if (colorScheme != nullptr) {
colorScheme->getColorTable(_colorTable);
} else {
for (int i = 0; i < TABLE_COLORS; i++) {
_colorTable[i] = ColorScheme::defaultTable[i];
}
std::copy_n(ColorScheme::defaultTable, TABLE_COLORS, _colorTable);
}
}
......
......@@ -78,10 +78,8 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
// If we should remove leading whitespace find the first non-space character
int start = 0;
if (!_includeLeadingWhitespace) {
for (start = 0; start < count; start++) {
if (!characters[start].isSpace()) {
break;
}
while (start < count && characters[start].isSpace()) {
start++;
}
}
......@@ -94,12 +92,8 @@ void PlainTextDecoder::decodeLine(const Character* const characters, int count,
// if inclusion of trailing whitespace is disabled then find the end of the
// line
if (!_includeTrailingWhitespace) {
for (int i = count - 1 ; i >= start ; i--) {
if (!characters[i].isSpace()) {
break;
} else {
outputCount--;
}
while(outputCount > 0 && characters[start + outputCount - 1].isSpace()) {
outputCount--;
}
}
......
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