[Qt-interest] QRegExp compilation

Bachrach, Robert L rob.bachrach at tycoelectronics.com
Wed Jan 13 19:20:12 CET 2010


Eric clark wrote:
> Someone recently posted some optimization help with regular
> expressions and strings and they mentioned that it is better to not
> have to recreate regular expressions if you use the same one numerous
> times because compilation is time consuming. I was wondering if the
> QRegExp class recompiles the regular expression when it is copied from
> one to the other? Or if the compilation is copied with the QRegExp?

I checked the QRegExp source code.  It appears the assignment operator (and, consequently, the copy constructor) attempt to share the regular expression state engine.  So, it appears that it does carry the "compilation" with the copy.

Rob




More information about the Qt-interest-old mailing list