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

Access changes in CompactHistoryScroll

Added access changes using 'at()' at reflow code to avoid deep copy.
parent 4ce6ea91
/*
SPDX-FileCopyrightText: 2021-2021 Carlos Alves <cbcalves@gmail.com>
SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de>
SPDX-License-Identifier: GPL-2.0-or-later
......@@ -6,7 +7,6 @@
// Own
#include "CompactHistoryScroll.h"
#include "CompactHistoryType.h"
using namespace Konsole;
......@@ -43,16 +43,6 @@ void CompactHistoryScroll::removeFirstLine()
}
}
inline int CompactHistoryScroll::lineLen(const int line) const
{
return line == 0 ? _index[0] : _index[line] - _index[line - 1];
}
inline int CompactHistoryScroll::startOfLine(const int line) const
{
return line == 0 ? 0 : _index[line - 1];
}
void CompactHistoryScroll::addCells(const Character a[], const int count)
{
std::copy(a, a + count, std::back_inserter(_cells));
......@@ -132,13 +122,13 @@ void CompactHistoryScroll::removeCells()
bool CompactHistoryScroll::isWrappedLine(const int lineNumber) const
{
Q_ASSERT(lineNumber < _index.size());
return (_flags[lineNumber] & LINE_WRAPPED) > 0;
return (_flags.at(lineNumber) & LINE_WRAPPED) > 0;
}
LineProperty CompactHistoryScroll::getLineProperty(const int lineNumber) const
{
Q_ASSERT(lineNumber < _index.size());
return _flags[lineNumber];
return _flags.at(lineNumber);
}
int CompactHistoryScroll::reflowLines(const int columns)
......
/*
SPDX-FileCopyrightText: 2021-2021 Carlos Alves <cbcalves@gmail.com>
SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de>
SPDX-License-Identifier: GPL-2.0-or-later
......@@ -7,11 +8,7 @@
#ifndef COMPACTHISTORYSCROLL_H
#define COMPACTHISTORYSCROLL_H
// STD
#include <deque>
#include "konsoleprivate_export.h"
#include "history/HistoryScroll.h"
namespace Konsole
......@@ -49,8 +46,16 @@ private:
int _maxLineCount;
void removeFirstLine();
inline int lineLen(const int line) const;
inline int startOfLine(const int line) const;
inline int lineLen(const int line) const
{
return line == 0 ? _index.at(0) : _index.at(line) - _index.at(line - 1);
}
inline int startOfLine(const int line) const
{
return line == 0 ? 0 : _index.at(line - 1);
}
};
}
......
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