Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/languagecontroller.cpp
Show First 20 Lines • Show All 257 Lines • ▼ Show 20 Line(s) | 255 | { | |||
---|---|---|---|---|---|
258 | QList<ILanguageSupport*> languages; | 258 | QList<ILanguageSupport*> languages; | ||
259 | 259 | | |||
260 | if(d->m_cleanedUp) | 260 | if(d->m_cleanedUp) | ||
261 | return languages; | 261 | return languages; | ||
262 | 262 | | |||
263 | const QString fileName = url.fileName(); | 263 | const QString fileName = url.fileName(); | ||
264 | 264 | | |||
265 | ///TODO: cache regexp or simple string pattern for endsWith matching | 265 | ///TODO: cache regexp or simple string pattern for endsWith matching | ||
266 | QRegExp exp("", Qt::CaseInsensitive, QRegExp::Wildcard); | 266 | QRegExp exp(QString(), Qt::CaseInsensitive, QRegExp::Wildcard); | ||
267 | ///non-crashy part: Use the mime-types of known languages | 267 | ///non-crashy part: Use the mime-types of known languages | ||
268 | for(LanguageControllerPrivate::MimeTypeCache::const_iterator it = d->mimeTypeCache.constBegin(); | 268 | for(LanguageControllerPrivate::MimeTypeCache::const_iterator it = d->mimeTypeCache.constBegin(); | ||
269 | it != d->mimeTypeCache.constEnd(); ++it) | 269 | it != d->mimeTypeCache.constEnd(); ++it) | ||
270 | { | 270 | { | ||
271 | foreach(const QString& pattern, it.key().globPatterns()) { | 271 | foreach(const QString& pattern, it.key().globPatterns()) { | ||
272 | if(pattern.startsWith('*')) { | 272 | if(pattern.startsWith(QLatin1Char('*'))) { | ||
273 | const QStringRef subPattern = pattern.midRef(1); | 273 | const QStringRef subPattern = pattern.midRef(1); | ||
274 | if (!subPattern.contains('*')) { | 274 | if (!subPattern.contains(QLatin1Char('*'))) { | ||
275 | //optimize: we can skip the expensive QRegExp in this case | 275 | //optimize: we can skip the expensive QRegExp in this case | ||
276 | //and do a simple string compare (much faster) | 276 | //and do a simple string compare (much faster) | ||
277 | if (fileName.endsWith(subPattern)) { | 277 | if (fileName.endsWith(subPattern)) { | ||
278 | languages << *it; | 278 | languages << *it; | ||
279 | } | 279 | } | ||
280 | continue; | 280 | continue; | ||
281 | } | 281 | } | ||
282 | } | 282 | } | ||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |