diff --git a/src/History.h b/src/History.h --- a/src/History.h +++ b/src/History.h @@ -141,7 +141,7 @@ private: int startOfLine(int lineno); - HistoryFile _index; // lines Row(int) + QVector _index; // lines Row(int) HistoryFile _cells; // text Row(Character) HistoryFile _lineflags; // flags Row(unsigned char) }; diff --git a/src/History.cpp b/src/History.cpp --- a/src/History.cpp +++ b/src/History.cpp @@ -226,14 +226,15 @@ HistoryScrollFile::HistoryScrollFile(const QString& logFileName) : HistoryScroll(new HistoryTypeFile(logFileName)) + , _index(QVector()) { } HistoryScrollFile::~HistoryScrollFile() = default; int HistoryScrollFile::getLines() { - return _index.len() / sizeof(int); + return _index.size(); } int HistoryScrollFile::getLineLen(int lineno) @@ -255,12 +256,7 @@ { if (lineno <= 0) return 0; if (lineno <= getLines()) { - if (!_index.isMapped()) - _index.map(); - - int res; - _index.get((unsigned char*)&res, sizeof(int), (lineno - 1)*sizeof(int)); - return res; + return _index.at(lineno-1); } return _cells.len(); } @@ -277,11 +273,7 @@ void HistoryScrollFile::addLine(bool previousWrapped) { - if (_index.isMapped()) - _index.unmap(); - - int locn = _cells.len(); - _index.add((unsigned char*)&locn, sizeof(int)); + _index.append(_cells.len()); unsigned char flags = previousWrapped ? 0x01 : 0x00; _lineflags.add((unsigned char*)&flags, sizeof(unsigned char)); }