diff options
| author | Igor Kushnir <igorkuo@gmail.com> | 2021-12-12 12:32:45 +0200 |
|---|---|---|
| committer | Igor Kushnir <igorkuo@gmail.com> | 2021-12-21 21:21:50 +0200 |
| commit | 0dbbda670d1e9f79d85edc1599315943d9eec33a (patch) | |
| tree | bd33abbddc0fba2aea43aaccb60705ae06cf6404 /src/corelib/tools/qringbuffer.cpp | |
| parent | 11409f4c023d7a9596ab5c0ca98256f650be9a90 (diff) | |
QMimeDatabasePrivate: deduplicate QStringLiteral
defaultMimeType() cannot be moved out of the class and defined in
qmimedatabase.cpp, because it is called from QMimeType::isDefault() in
qmimetype.cpp.
Return m_defaultMimeType constant by reference rather than by value from
the inline helper function. This eliminates useless copying of QString
when calling code needs only a reference, and so improves performance.
Even though m_defaultMimeType is initialized with a QStringLiteral and
its QArrayDataPointer has d == nullptr, QArrayDataPointer's ref() and
deref() still have to compare d with nullptr to decide that no reference
count manipulation is needed. Compilers might be unable to reorder these
checks with surrounding code because they guard reference count
manipulation. Branch misprediction could further harm performance.
Optimizing these checks out can be difficult for compilers.
Change-Id: I3ffa0fdc5ad948452301dd9688073b5323a7983b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qringbuffer.cpp')
0 files changed, 0 insertions, 0 deletions
