-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: replace QString() with QStringLiteral() for better performance #11454
base: master
Are you sure you want to change the base?
Conversation
Can you please provide more information on what situations you were seeing a performance issue that lead to this change? Also what testing was done to show this had improved performance? |
Qt Documentation says
From my perspective, the actual difference is not apparent (slightly faster) |
The key part here is "data known at compile time". Most of these instances have |
Function signatures doesn't need to change, as the generated type of |
Pretty much all of these are cold paths rather than hot paths. I don't necessarily disagree with doing it but I'm just noting that it's not really all that significant to have occasional allocations in a cold path. Not sure if it's worth the commit but I don't particularly feel strongly about it one way or the other. |
I think the important distinction of this PR is to use It would be similar to storing a template literal like "My String with argument %1" as a Some more explanation about its benefits can be found here: https://woboq.com/blog/qstringliteral.html |
I compared the time of Below is the measurement with ~1000 calls of
Also the PR needs to follow the commit guideline. The modification should be separated for each module such as UI, obs-vst, etc. and the commit title should start with the module name. |
When making code refactoring PR, each module should be made separately? |
Yes, at the very least for each "part" of the program, i.e. separate commits for I think it's important to point out that using
So in the same way we use Any performance benefits are just icing on the cake. |
a9c8cde
to
fc46b2a
Compare
I just shrank the scope of this PR to UI only |
I'll defer to Pat on this one. |
Description
QStringLiteral()
provides better performance thanQString()
when constructing QString objects.Motivation and Context
QStringLiteral()
, which makes constructing QString objects from string literals more efficient.How Has This Been Tested?
Types of changes
Performance enhancement (non-breaking change which improves efficiency)
Code cleanup (non-breaking change which makes code smaller or more readable)
Checklist: