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
data.
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
move.
The time that it takes to search a collection of just too many strings
can take up to 48msec - tested triggering the code on /usr/lib with
around 7000 files.
changing to QSet this went down to 35msec. This is not a lot but
it's triggered at *every* mouse move event, so the gain is cummulative
The whole experience is a bit smoother.
The original regexp was two pages long and was quite complex to debug
Let's start small. This fixes a few bugs matching files, starts to
match folders too (which is userfull if we want to open a folder in
dolphin for instance) and works correctly with quoted files and spaces.
When creating HotSpot's for local files, create them for files in the
current dir and for files in sub-directories too.
Re-format the code used to build the regex pattern for more readability
(easier for seeing what the regex pattern will look like, I hope).
Use a static QRegularExpression object, so as to only construct it once,
the pattern doesn't change and this should help with performance. Also
make createFileRegex() not static.
Don't convert QList<QString> to QSet<QString>, without actual benchmarking
it could be that QList is actually efficient here.
Use const where appropriate.
BUG: 416376
The actions are destroyed during a focusIn / focusOut, and recreated
with the same content but different memory positions, and that
killed the QActions inside of the menu.
To trigger this is simple, open the search bar, type some url in
konsole, and right click on it: you will not see the actions
to copy and go to url.
moving the related code to QSharedPointer fixes this by delaying
the destruction of the pointer untill the menu is closed.
Summary:
Fixes memory leaf of HotSpots. This is caused by the Filter::reset()
function failing to delete the allocated HotSpots before clearing the
list.
Test Plan:
Compile konsole with address sanitizer
Select a link in the terminal
Close konsole
Reviewers: #konsole, hindenburg
Reviewed By: #konsole, hindenburg
Subscribers: hindenburg, konsole-devel
Tags: #konsole
Differential Revision: https://phabricator.kde.org/D19636
Summary:
Replaces direct konsole_wcwidth() calls with Character object property
and the class static function, which internally still use
konsole_wcwidth().
The change also prepares the codebase for a new code for determining
character width. This way the change will barely touch existing code.
CCBUG: 396435
Test Plan:
konsole_wcwidth() is still used, just in one central place. Passed
compilation and CharacterWidthTest should be enough.
Reviewers: #konsole, hindenburg
Reviewed By: #konsole, hindenburg
Subscribers: hindenburg, konsole-devel
Tags: #konsole
Differential Revision: https://phabricator.kde.org/D15756
Match files with known prefixes and full names.
Also cache known files instead of looking up and creating a QDir and
QFileInfo for every file, to improve performance massively.
REVIEW: 128396