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)
- Branch
- master
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 12840 Build 12858: arc lint + arc unit
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 ↗ | (On Diff #59772) | Are you sure you uploaded the right diff? No const static, Q_ASSERT ... |
src/plasma/svg.cpp | ||
---|---|---|
123 ↗ | (On Diff #59772) | static isn't necessary, QRegularExpression already has internal regex compilation optimisations we can leverage. |
src/plasma/svg.cpp | ||
---|---|---|
123 ↗ | (On Diff #59772) | 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 ↗ | (On Diff #59772) | pcre2 does it, AFAIK. |
src/plasma/svg.cpp | ||
---|---|---|
123 ↗ | (On Diff #59772) | Benchmark tells const static is faster: |