Don't double-access maps
Don't construct ids more times than necessary.
Make regular expression static so it's not compiled on every run.
Remove unused code.
Details
- Reviewers
davidedmundson - Group Reviewers
Plasma Frameworks - Commits
- R242:097f0e83e7bf: Make Plasma::Svg::elementRect a bit leaner
Diff Detail
- Repository
- R242 Plasma Framework (Library)
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Please put the dead code removal in a separate review.
src/plasma/svg.cpp | ||
---|---|---|
121–122 | Please use a QRegularExpression with lazy quantifiers, you can use const static then, no need for QRegExp.setMinimal(true). |
src/plasma/svg.cpp | ||
---|---|---|
123 | Are you sure you uploaded the right diff? No const static, Q_ASSERT ... |
src/plasma/svg.cpp | ||
---|---|---|
123 | static isn't necessary, QRegularExpression already has internal regex compilation optimisations we can leverage. |
src/plasma/svg.cpp | ||
---|---|---|
123 | Are you sure about this? As far as I can see: QRegularExpression::QRegularExpression(QString pattern) default constructs a QRegularExpressionPrivate, which sets dirty(true). Calling QRE::globalMatch() calls QREPrivate::compilePattern, which calls pcre2_compile_16 and pcre2_jit_compile_16. I don't see any caching here. |
src/plasma/svg.cpp | ||
---|---|---|
123 | pcre2 does it, AFAIK. |
src/plasma/svg.cpp | ||
---|---|---|
123 | Benchmark tells const static is faster: |