Skip to content
Commit 49c41c2b authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Optimize LanguageController's MimeTypeCache: QMultiHash suffixes

The performance gains are not very significant, but the code becomes
shorter as well, so there seem to be no drawbacks to this change.

Average BenchLanguageController results before and at this commit in
milliseconds per iteration:
        Data row                    Before      At
1. benchLanguagesForUrlNoCache()
    CMakeLists                      0.00045     0.00046
    cmakelists wrong case           0.00045     0.00046
    lower-case                      0.00045     0.00040
    upper-case                      0.00045     0.00039
    mixed-case                      0.00045     0.00040
    .C                              0.00037     0.00040
    .cl                             0.00038     0.00038
    existent C with extension       0.00043     0.00045
    .cc                             0.00040     0.00039
    .cmake                          0.00041     0.00044
    .diff                           0.00038     0.00040
    .qml                            0.00037     0.00039
    existent C w/o extension        0.16        0.16
    existent patch w/o extension    0.20        0.20
2. benchLanguagesForUrlFilledCache()
    CMakeLists                      0.00048     0.00050
    cmakelists wrong case           0.00049     0.00050
    lower-case                      0.00048     0.00041
    upper-case                      0.00049     0.00041
    mixed-case                      0.00049     0.00042
    .C                              0.00041     0.00042
    .cl                             0.00045     0.00042
    existent C with extension       0.00047     0.00047
    .cc                             0.00044     0.00041
    .cmake                          0.00042     0.00043
    .diff                           0.00041     0.00041
    .qml                            0.00045     0.00043
    existent C w/o extension        0.16        0.16
    existent patch w/o extension    0.20        0.20

Note: benchLanguagesForUrlNoMatch*() benchmark results are practically
unaffected by this commit because the QMimeDatabase::mimeTypeForFile()
call is orders of magnitude slower than the
MimeTypeCache::languagesForFileName() call optimized here.

The benchmarks run slightly faster on average now.
benchLanguagesForUrlFilledCache(), which is closest to the real-life
LanguageController usage in KDevelop, got a 14% speedup for the common
*.cpp pattern data rows ("lower-case", "upper-case" and "mixed-case").
parent 59270583
Pipeline #96960 passed with stage
in 33 minutes and 46 seconds
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