On Nov 25, 2011, at 4:50 AM, ext Giuseppe D'Angelo wrote: > On 24 November 2011 22:49, Oswald Buddenhagen > <[email protected]> wrote: >> On Wed, Nov 23, 2011 at 03:35:57PM +0100, ext Thiago Macieira wrote: >>> At first thought, I'd say that the pattern class should be a regular, >>> implicitly-shared, atomic copy-on-write value class. If you call a non-const >>> method, it detaches. >>> >>> There should be no const methods that modify internal caches. Period. If you >>> compile the pattern, it's a non-const method and it detaches. >>> >> that makes lazy compilation really tough to implement ... > > The problem is the API... given the fact that every method that > somehow executes the regexp has to compile it first, does an user > expect reasonably that const methods (on a value based, implicitly > shared class) like isValid(), indexIn(), exactMatch(), etc. cache the > compiled pattern or not? > > Where, in the following lines, should the pattern be compiled? The > compilation result should be kept in cache at that point? > > QRegExp rx("a complicated regexp"); > if (rx.isValid()) { > index1 = rx.indexIn(str1); > index2 = rx.indexIn(str2); // will pay for another compilation of > the pattern? > }
What is the use case for *not* compiling in the constructor? And how is an uncompiled Regular Expression object different from, say, a QString? Cheers, João _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
