OTWO-803 Fixes disambiguate_pp() performance sink
authorRobin Luckey <rluckey@blackducksoftware.com>
Mon, 20 Jun 2011 15:28:44 +0000 (11:28 -0400)
committerRobin Luckey <rluckey@blackducksoftware.com>
Mon, 20 Jun 2011 15:28:44 +0000 (11:28 -0400)
commitf2559100209b85185467f9f0c5caca350df0d50f
tree148a10a140568d196342ac48431b18857e25850e
parent3d6c5b9e0cfb7c3bdfc74e0a6face0110466a7b0
OTWO-803 Fixes disambiguate_pp() performance sink

disambiguate_pp() failed to execute in a reasonable time for extremely
large (1MB+) files.

The reason is that a regular expression is evaluated for each line of
the file, and this regular expression is scoped from the beginning of
the line to the end of the file. When the file is extremely large,
the regular expression evaluation runs away with the CPU.

By limiting the scope of the regular expression evaluation to no more
than 100 characters from its start point, we can avoid the runaway
performance sink. This is a reasonable change since the expression we
are looking to match should almost always fit within 100 chars anyway.
src/detector.c