forked from qt-creator/qt-creator
		
	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
This commit is contained in:
		@@ -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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user