feature #1503 Use LimitIterator on Iterable objects within the slice filter (Anthony Sterling)
feature #1503 Use LimitIterator on Iterable objects within the slice filter (Anthony Sterling)

This PR was merged into the 1.16-dev branch.

Discussion
----------

Use LimitIterator on Iterable objects within the slice filter

Previously the `slice` filter would create an array of items if the subject to be sliced implemented Traversable, this PR instead passes the subject to LimitIterator first - but only if `$start` and `$length` are positive values as LimitIterator does not support the "n'th from end" behaviour.

Our use case is that we have an API client, which we pass to slice, that implements Traversable but lazy loads the items to be returned via an API when `Iterator::current()` is called. Here a quick example:-

```
{% for item in client.items | slice(0,5) %}
    {{ item.name }}
{% endfor %}

<img src="/assets/useless-sodding-banner.jpg" />

{% for item in client.items | slice(5,10) %}
    {{ item.name }}
{% endfor %}
```

Current behaviour would mean that the client would issue 15 requests to the API, 5 for the first block, and 10 for the second (but only return items 5 to 10). This PR means only 10 requests are made, 5 in each block.

I'd imagine this would lower memory usage too.

Commits
-------

fdddb1c Use LimitIterator on Iterable objects within the splice filter

znerol/Twig,gamernetwork/Twig,hhamon/Twig,twigphp/Twig,jamessingizi/Twig,hhamon/Twig,nicolas-grekas/Twig,hason/Twig,nicolas-grekas/Twig,Rvanlaak/Twig,jamessingizi/Twig,znerol/Twig,fsw/Twig,moufmouf/Twig,hhamon/Twig,loi-chuanoi/Twig,derickr/Twig,nicolas-grekas/Twig,jamessingizi/Twig,huang53798584/Twig,bocharsky-bw/Twig,Tobion/Twig,Tobion/Twig,dkarvounaris/Twig,robregonm/Twig,moltin/Twig,gamernetwork/Twig,iKwinto/Twig,Rvanlaak/Twig,craue/Twig,dkarvounaris/Twig,derickr/Twig,twigphp/Twig,gencer/Twig,framewr/Twig,moltin/Twig,apishka/templater,fsw/Twig,craue/Twig,derickr/Twig,gamernetwork/Twig,huang53798584/Twig,huang53798584/Twig,nicolas-grekas/Twig,gencer/Twig,Rvanlaak/Twig,nicolas-grekas/Twig,znerol/Twig,iKwinto/Twig,moufmouf/Twig,twigphp/Twig,moltin/Twig,robregonm/Twig,framewr/Twig,hason/Twig,dkarvounaris/Twig,hason/Twig,robregonm/Twig,bocharsky-bw/Twig,bocharsky-bw/Twig,fsw/Twig,iKwinto/Twig,Tobion/Twig,moufmouf/Twig,framewr/Twig,apishka/templater