improved the performance of the Twig loader by not registering a chain loader if not needed
merged branch fabpot/twig-perf (PR #635)

This PR was merged into the master branch.

Commits
-------

7e554db improved the performance of the Twig loader by not registering a chain loader if not needed

Discussion
----------

improved the performance of the Twig loader by not registering a chain loader if not needed

When `twig.templates` is empty, there is no need to register the Twig array loader as it will never be used anyway.

---------------------------------------------------------------------------

by lyrixx at 2013-02-18T09:50:07Z

totally :+1: More over, I think this feature was not documented.

---------------------------------------------------------------------------

by GromNaN at 2013-02-18T10:04:32Z

Nice tip. How much is it more performant ?

@lyrixx it is documented here : http://silex.sensiolabs.org/doc/providers/twig.html#parameters

---------------------------------------------------------------------------

by fabpot at 2013-02-18T10:06:17Z

It's not really about how much but just keeping the array loader around is a waste of time.

---------------------------------------------------------------------------

by igorw at 2013-02-18T13:37:58Z

:-1: This prevents extending the `twig.loader` service and also feels like a micro-optimization to me.

---------------------------------------------------------------------------

by fabpot at 2013-02-18T13:57:13Z

I've removed the optimization but I've kept the different order in registration as it makes more sense.

---------------------------------------------------------------------------

by igorw at 2013-02-18T13:59:55Z

:+1: