Clean up some coding standard violations in MIME type code
Trivia, noticed while assessing security risk. Stray braces where they aren't needed. Long lines: reflowed comments and split a declaration. Task-number: QTBUG-135191 Change-Id: I3e19673fc35bd7ee12a6e62849d12810e8997cdf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
578852f4ca
commit
4b3a1bf272
@ -394,9 +394,9 @@ QMimeType QMimeDatabasePrivate::mimeTypeForFileNameAndData(const QString &fileNa
|
||||
if (candidateByData.isValid() && magicAccuracy > 0) {
|
||||
const QString sniffedMime = candidateByData.name();
|
||||
// If the sniffedMime matches a highest-weight glob match, use it
|
||||
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime)) {
|
||||
if (candidatesByName.m_matchingMimeTypes.contains(sniffedMime))
|
||||
return candidateByData;
|
||||
}
|
||||
|
||||
for (const QString &m : std::as_const(candidatesByName.m_allMatchingMimeTypes)) {
|
||||
if (inherits(m, sniffedMime)) {
|
||||
// We have magic + pattern pointing to this, so it's a pretty good match
|
||||
|
@ -191,9 +191,9 @@ void QMimeAllGlobPatterns::addGlob(const QMimeGlobPattern &glob)
|
||||
const QString &pattern = glob.pattern();
|
||||
Q_ASSERT(!pattern.isEmpty());
|
||||
|
||||
// Store each patterns into either m_fastPatternDict (*.txt, *.html etc. with default weight 50)
|
||||
// or for the rest, like core.*, *.tar.bz2, *~, into highWeightPatternOffset (>50)
|
||||
// or lowWeightPatternOffset (<=50)
|
||||
// Store each patterns into either m_fastPatternDict (*.txt, *.html
|
||||
// etc. with default weight 50) or for the rest, like core.*, *.tar.bz2, *~,
|
||||
// into highWeightPatternOffset (>50) or lowWeightPatternOffset (<=50).
|
||||
|
||||
if (glob.weight() == 50 && isFastPattern(pattern) && !glob.isCaseSensitive()) {
|
||||
// The bulk of the patterns is *.foo with weight 50 --> those go into the fast patterns hash.
|
||||
@ -249,12 +249,11 @@ void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatch
|
||||
const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension);
|
||||
const QString simplePattern = "*."_L1 + simpleExtension;
|
||||
for (const QString &mime : matchingMimeTypes) {
|
||||
if (filterFunc(mime)) {
|
||||
if (filterFunc(mime))
|
||||
result.addMatch(mime, 50, simplePattern, simpleExtension.size());
|
||||
}
|
||||
}
|
||||
// Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway,
|
||||
// at least those with weight 50.
|
||||
// Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the
|
||||
// low-weight mimetypes anyway, at least those with weight 50.
|
||||
}
|
||||
|
||||
// Finally, try the low weight matches (<=50)
|
||||
|
@ -45,7 +45,9 @@ public:
|
||||
static const unsigned DefaultWeight = 50;
|
||||
static const unsigned MinWeight = 1;
|
||||
|
||||
explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType, unsigned theWeight = DefaultWeight, Qt::CaseSensitivity s = Qt::CaseInsensitive) :
|
||||
explicit QMimeGlobPattern(const QString &thePattern, const QString &theMimeType,
|
||||
unsigned theWeight = DefaultWeight,
|
||||
Qt::CaseSensitivity s = Qt::CaseInsensitive) :
|
||||
m_pattern(s == Qt::CaseInsensitive ? thePattern.toLower() : thePattern),
|
||||
m_mimeType(theMimeType),
|
||||
m_weight(theWeight),
|
||||
|
Loading…
x
Reference in New Issue
Block a user