Try not to access hashes repeatedly.
QRegExp -> QRegularExpression.
Details
- Reviewers
mart fvogt - Group Reviewers
Plasma Frameworks - Commits
- R242:6c692309edf7: Better use of Qt APIs in Plasma::Theme
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.
src/plasma/svg.cpp | ||
---|---|---|
313 | When you make it static it would only have to compile it once | |
src/plasma/theme.cpp | ||
104 | Can we clean up all of this custom refcounting by using a QSharedPointer? | |
323–324 | So this code removes the item if already existing and then inserts it again? This thing is a QHash so insert will just override the existing one anyway, no need to remove it first. |
src/plasma/theme.cpp | ||
---|---|---|
104 | Implemented with QSharedData. |
src/plasma/svg.cpp | ||
---|---|---|
317 | isValid is always true, you probably want to use hasMatch instead. This is not obvious, I only noticed this because I debugged this error before (https://phabricator.kde.org/D17359) |
src/plasma/svg.cpp | ||
---|---|---|
339–364 | What's this doing? it seems that it calculates the bestFit just to discard later. |
src/plasma/svg.cpp | ||
---|---|---|
342–349 | looks a good example of code that could be written with an std::find_if |
src/plasma/svg.cpp | ||
---|---|---|
317 | It really does not look that way as you're immediately using captures after that. If that's really what you want (which I doubt), it should be sizeHintedKeyExpr.isValid() instead and be done before the foreach. Currently it would just add QSize(0, 0) to elementsWithSizeHints even for "öoiawze9pv5z2p3v4" as key. |
src/plasma/svg.cpp | ||
---|---|---|
342–349 | You either have to sort on bestFit.area() first, or do the find_if in a nested loop, to find a better match (smaller one) after the first one. | |
346 | can you swap bestFit and hint (and reverse the >) here, makes it easier to read IMHO (i.e. the comment says "smallest one", so the check should be <). |
src/plasma/svg.cpp | ||
---|---|---|
317 | You're right, I looked at the wrong code. Fixed now. |
@apol This patch seems to have caused a bug in the way icons are loaded for the system tray:
The largest icon available from the desktop theme is used instead of the correct size.
When I compile plasma-framework without this patch, the system tray looks how it should:
src/plasma/svg.cpp | ||
---|---|---|
313 | Oh, I think the static might be the culprit, I didn't realize the status and ratio were changing. Sorry |
src/plasma/svg.cpp | ||
---|---|---|
313 |
Try removing .cache/plasma-svgelements-default_v5.60.0 and .cache/plasma_theme_default_v5.60.0.kcache.