mnunberg/Constant-Generate — pull request #1 by neilbowers (2012-01-29 20:01:18+00:00)
Title: Performance improvement for scalar constants

Hi,

When benchmarking the various constant modules, Constant::Generate was significantly slower than most.
For scalars, it was taking about 26 seconds to run the test.

In _gen_constant() it was doing:

*{$fqname} = sub () { $values[0] };

This means it was accessing the array every time you access the constant. So I just pulled the value out of the array, and used a scalar value in the above line.

Now the test takes around 5 seconds, and brings Constant::Generate in line with most modules.

Neil