Commit 93195356 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen

mime type matching optimization

given that checking for a match is expensive and determining the
priority is cheap, it makes sense to match only if the priority is known
to be high enough.

Reviewed-by: Leandro Melo
parent f3d6cd9c
......@@ -724,11 +724,9 @@ unsigned MimeType::matchesData(const QByteArray &data) const
unsigned priority = 0;
if (!data.isEmpty()) {
foreach (const IMagicMatcher::IMagicMatcherSharedPointer &matcher, m_d->magicMatchers) {
if (matcher->matches(data)) {
const unsigned magicPriority = matcher->priority();
if (magicPriority > priority)
priority = magicPriority;
const unsigned magicPriority = matcher->priority();
if (magicPriority > priority && matcher->matches(data))
priority = magicPriority;
return priority;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment