Optimize ArchiveModel::cleanFileName
ClosedPublic

Authored by nicolasfella on Nov 27 2019, 12:08 PM.

Details

Summary

Creating the QRegularExpression is expensive and cleanFileName is called for each entry. By not re-creating the regex we gain a significant archive load time improvement

Test Plan

Left is before, right is after. Note the red block on the left that isn't present on the right

Diff Detail

Repository
R36 Ark
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella created this revision.Nov 27 2019, 12:08 PM
Restricted Application added a project: Ark. · View Herald TranscriptNov 27 2019, 12:08 PM
Restricted Application added a subscriber: kde-utils-devel. · View Herald Transcript
nicolasfella requested review of this revision.Nov 27 2019, 12:08 PM
nicolasfella edited the test plan for this revision. (Show Details)Nov 27 2019, 12:09 PM

Interesting. How did you test this? Just opening an archive?

part/archivemodel.cpp
347

Why remove the debug line though?

nicolasfella added a comment.EditedJan 2 2020, 12:15 AM

I tested it by opening a rather large zip (the Android NDK).

The culprit seems to be frequent re-creation of the QRegularExpression object. Since we don't change it we can share it between the function calls which simplifies the patch and keeps the exact original behavior.

Simpler approach

nicolasfella marked an inline comment as done.Jan 2 2020, 12:19 AM
elvisangelaccio accepted this revision.Jan 2 2020, 12:30 PM

Please update the commit message before pushing.

This revision is now accepted and ready to land.Jan 2 2020, 12:30 PM
nicolasfella edited the summary of this revision. (Show Details)Jan 2 2020, 3:01 PM
This revision was automatically updated to reflect the committed changes.