Skip to content

Repository::definitionsForFileName: don't detach a temporary QVector

Igor Kushnir requested to merge work/no-detaching-of-wildcards into master

This optimization makes both Repository::definitionForFileName() and definitionsForFileName() two times faster.

KateModeManager::wildcardsFind() remains much faster than Repository::definitionForFileName(). The main factors that slow definitionForFileName() down are:

  1. Definition::extensions() returns a QVector by value. Making this function return const QVector & speeds the benchmark up by 25-40%.
  2. Unlike wildcardsFind(), definitionForFileName() does not skip matching patterns from types of same or lower priority compared to an already found type.
  3. Definition::extensions() is not inline, while wildcardsFind() accesses the KateFileType::wildcards data member directly.
  4. The default constructor of Definition() is expensive. This slows down definitionForFileName() when there is no match.

Merge request reports