puppetlabs/puppetlabs-apt — pull request #375 by raphink (2014-10-15 13:49:08+00:00)
Title: Refactor facts to improve performance:

* Add an apt_has_updates boolean fact
* Make other facts depend on it

These facts call the `apt-check` command 3 times for every run. This command usually takes 2 seconds or more to return, thus taking 6 seconds or more just for these 3 facts.

This PR proposes a refactoring which runs the command only once when no packages need to be updated, and twice if packages need updating (to get the package names).

I am well aware that it puts global variables outside of `setcode` blocks, but it adds a great performance gain.