QMimeDatabasePrivate: remove duplicate else-if branch

In mimeTypeForFileExtension(), the `else if (matchCount == 1)` branch
differs from the `else` branch only in a comment. Remove the branch with
duplicate code, adjust the comment and simplify the `if` condition.

Change-Id: Ib97a057880373ab3ab9b585e688b38fe1f542ba2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Igor Kushnir 2021-12-11 17:47:58 +02:00
parent 02f14d7afe
commit 49b726fa71
1 changed files with 2 additions and 5 deletions

View File

@ -440,13 +440,10 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
QMimeType QMimeDatabasePrivate::mimeTypeForFileExtension(const QString &fileName)
{
const QStringList matches = mimeTypeForFileName(fileName);
const int matchCount = matches.count();
if (matchCount == 0) {
if (matches.isEmpty()) {
return mimeTypeForName(defaultMimeType());
} else if (matchCount == 1) {
return mimeTypeForName(matches.first());
} else {
// We have to pick one.
// We have to pick one in case of multiple matches.
return mimeTypeForName(matches.first());
}
}