Remove mime type <-> extension cache
ClosedPublic

Authored by brauch on Oct 12 2016, 9:07 PM.

Details

Summary

The idea that because one file with extension X has mime type A,
determined by its contents, hence other files with extension X will
have the same mime type is just wrong. One common example where this
breaks in a spectacular way is CMakeLists.txt and the .txt extension.

I found the claim that looking into each file will make the application
unresponsive to be unfounded. QMimeType will only read the first 16kB to
guess the mime type, which takes less than a millisecond for each file.
A test project with three hundred 3 MB binary blobs still loads instantly.
If, in comparison, we parse one of the files as CMake erraneously, we
take multiple seconds.

CCBUG:363269

Diff Detail

Repository
R33 KDevPlatform
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
brauch updated this revision to Diff 7361.Oct 12 2016, 9:07 PM
brauch retitled this revision from to Remove mime type <-> extension cache.
brauch updated this object.
brauch edited the test plan for this revision. (Show Details)
brauch added reviewers: kfunk, mwolff.
brauch set the repository for this revision to R33 KDevPlatform.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptOct 12 2016, 9:07 PM
kfunk accepted this revision.Oct 12 2016, 9:18 PM
kfunk edited edge metadata.

Looks fine to me.

Note that for all files where we have a language plugins providing a pattern (e.g. *.cpp, *.h, etc.) we don't even run into this code, in other words we will never run mime type detection on those. The performance impact of this patch seems negligible to me.

This revision is now accepted and ready to land.Oct 12 2016, 9:18 PM
This revision was automatically updated to reflect the committed changes.