Silly CMake 2.8.2 regex causing slow project load in KDevelop

Andreas Pakulat apaku at gmx.de
Mon Jul 19 13:07:09 UTC 2010


On 19.07.10 09:21:16, Andreas Pakulat wrote:
> On 18.07.10 23:35:36, Nicolás Alvarez wrote:
> > Since I upgraded to CMake 2.8.2, KDevelop takes almost four minutes to
> > load my project, before it appears in the Project toolview and C++
> > parsing starts. I tracked it down to a very slow regex in
> > FindZLIB.cmake:
> > 
> >    FILE(READ "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H)
> >    STRING(REGEX REPLACE ".*#define ZLIB_VERSION
> > \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*" "\\1.\\2.\\3"
> > ZLIB_VERSION_STRING "${ZLIB_H}")
> > 
> > On my machine, and with my zlib.h, QRegExp takes 3 minutes 55 seconds
> > to process the regex (measured, test case attached),
> 
> Hmm, just tried this and if I generate a release-build for your sample
> then it takes less than a fraction of a second to run it. If I change
> the qmake project to do a debug build it indeed takes a long time to do
> the replacement.
> 
> Whats the expected output of your app for the 4-digit and 3-digit
> version number? The reason I'm asking is that I get different output
> depending on release/debug mode compilation for the 3-digit zlib version
> (the 4-digit always prints out "" as 3rd line).

Hmm, this testcase is rather strange here on my laptop. I've replaced
the QString::replace with QString::indexOf() as thats more clear wether
something was matched or not. I'm using Qt4.6.2 here. The result is:

debug build, 4 digit version number:
I've cancelled this after 5 minutes, seems to hit some kind of endless
loop in QRegExp

debug build, 3 digit version number:
Instant, with proper result.

release build, 4 digit version number:
Instant, wrong result, I get -1!

release build, 3 digit version number:
Instant, wrong result, I get -1!

Does anybody else see this?

Andreas

-- 
Your lucky number has been disconnected.




More information about the KDevelop-devel mailing list