Migrate some QRegExps to QRegularExpression
ClosedPublic

Authored by dhaumann on Dec 4 2017, 1:47 PM.

Details

Summary

Please make a careful review. Many of these code
changes are most likely not touched by our unit tests, so
introducing regressions may happen quickly.

Test Plan

make && make test

Diff Detail

Repository
R39 KTextEditor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dhaumann created this revision.Dec 4 2017, 1:47 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptDec 4 2017, 1:47 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
dhaumann requested review of this revision.Dec 4 2017, 1:47 PM
mwolff requested changes to this revision.Dec 5 2017, 9:24 AM
mwolff added inline comments.
src/completion/katewordcompletion.cpp
316

hrm indeed :D wth? ;-)

478

here and below: can you use capturedRef instead?

src/mode/katemodemanager.cpp
165

why is this using a regexp? the match group isn't used at all, and the .* can be anything, including empty. So this is the same as varLine.contains(QLatin1String("kate:"))

src/printing/printpainter.cpp
289

fix old typo: tjeck -> check

src/utils/katecmds.cpp
207

future cleanup: use splitRef instead, if possible.

502–504

static?

514–518

this should be split into two branches and then use cmd.remove(0, 1) and cmd.remove(0, 2) respectively

This revision now requires changes to proceed.Dec 5 2017, 9:24 AM
dhaumann updated this revision to Diff 23488.Dec 5 2017, 11:50 AM

Fix remarks by Milian.

dhaumann updated this revision to Diff 23491.Dec 5 2017, 11:58 AM
dhaumann marked 4 inline comments as done.

Remove one usage of QRegularExpression

dhaumann marked an inline comment as done.Dec 5 2017, 11:59 AM

Update patch.

src/utils/katecmds.cpp
502–504

I do not think static is needed here: When you invoke the command line (F7), and type 'char 0x123', then creating a QRegularExpression will not be a bottleneck.

mwolff accepted this revision.Dec 5 2017, 1:18 PM
mwolff added inline comments.
src/document/katedocument.cpp
4475

future: this could be a ref, quite probably, and capturedRef could be used below

4517

future: someone should make this a static const array and use an initializer list

src/mode/katemodemanager.cpp
165

even better: !varLine.contains(QLatin1String("kate:")), or even startsWith? though the old code did a contains check

This revision is now accepted and ready to land.Dec 5 2017, 1:18 PM
This revision was automatically updated to reflect the committed changes.