monkey_patch: cache Symbol to_proc result.
If we use it, our monkey-patch version of Symbol to_proc is worth caching the
resulting proc - the hit rate is through the roof, because we only really act
on a small set of symbols.
This reduces some extra object and memory allocation by reusing the same proc
every time we transform the same symbol.
That saves 99.84 percent of the memory allocated from this method - about four
percent of the total memory allocation in my test run of Puppet with real
manifests and behaviours. (About 10MB out of 260MB originally; 26kb after.)
This applies to all versions - newer Rubies with a real implementation of
to_proc don't cache the result, so we do it for them.
Older versions *cough* 1.8.5 *cough* still get our hand-written implementation
of the proc, so that they work. It probably is equivalent to the real version,
but I would rather allow core changes to show.
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Conflicts:
lib/puppet/util/monkey_patches.rb
Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>