separate dynamic StringDetect rule to avoid copies in StringDetect::doMath()
The ternary in the previous code makes a systematic call to the constructor of QString:
const auto &pattern = m_dynamic ? replaceCaptures(....) : m_string;
^ QString ^ QString &
Common type is QString, m_string is implicitly transformed to QString(m_string) (pattern is a reference to a temporary object with an extended lifetime)
The creation of DynamicStringDetect allows a small additional gain.
highlighter_benchmark:
_ | Time |
---|---|
before | ~22.7s |
after | ~22.2s (-2%) |
Edited by jonathan poelen