Revision 880c7a4...

Go back to digest for 17th March 2013

Optimization in KDE-PIM

Jan Kundrát committed changes in [trojita] src/Composer/PlainTextFormatter.cpp:

HTML: scan the input using a single regular expression

This improves speed "a lot" -- previously, each pattern was tried until the end
of the input string after each and every match. This could easily lead to O(n^2)
complexity because it was easy to feed this with an input which e.g. matched
simple HTTP links all the time, but the whole rest of the input was repeatedly
scanned for a regexp matching an e-mail address all the time.

I haven't bothered with measurements (the old version did not finish in 30
minutes under callgrind when fed with a particularly malicious input).

Also make sure that all special metacharacters are properly escaped, that we
don't use locale-aware matching too much, and switch to RegExp2 for better Qt5

File Changes

Modified 1 files
  • src/Composer/PlainTextFormatter.cpp
1 files changed in total