Commit e713c90c authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Only recalculate the directories when we change dirs

Whenever we trigger something that redraws the screen we trigger
all the filters, and the FileFilter - that looks for files and folders
in the current directory - is constantly re-triggered to.

The creation of the vector / set containing all files takes now around
30msec, but searching takes just 3 - 4 msec. If we only generate the
list of files when we change directories, this goes down from 34 msec
to just 4, making konsole consume less cpu, spend less energy and help
with battery when we are selecting text or updating the screen with new

This fails to highlight a file if the file is created after we read the
files in the directory, as we are not updating the list of files
anymore. Not an acceptable loss, we need to fix this, but not by
re-reading all of the files in folders and subfolders on every mouse
parent 0b489b0c
......@@ -505,15 +505,19 @@ QSharedPointer<Filter::HotSpot> FileFilter::newHotSpot(int startLine, int startC
void FileFilter::process()
const QDir dir(_session->currentWorkingDirectory());
_dirPath = dir.canonicalPath() + QLatin1Char('/');
// Do not re-process.
if (_dirPath != dir.canonicalPath() + QLatin1Char('/')) {
_dirPath = dir.canonicalPath() + QLatin1Char('/');
const auto tmpList = dir.entryList(QDir::Dirs | QDir::Files);
_currentDirContents = QSet<QString>(std::begin(tmpList), std::end(tmpList));
_currentDirContents = QSet<QString>::fromList(dir.entryList(QDir::Dirs | QDir::Files));
_currentDirContents = QSet<QString>::fromList(dir.entryList(QDir::Dirs | QDir::Files));
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