Fix `extract` method to avoid recalculating count() for each iteration.

Cache the value of `count($attributes)` to avoid recalculating it for each iteration of the loop.

Since this count will never change during the method execution, this change make the code a bit more efficient.
minor #9651 Fix `extract` method to avoid recalculating count() for each iteration. (fabpot)

This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #9651).

Discussion
----------

Fix `extract` method to avoid recalculating count() for each iteration.

This PR was submitted on the symfony/DomCrawler read-only repository and moved automatically to the main Symfony repository (closes symfony/DomCrawler#16).

Cache the value of `count($attributes)` to avoid recalculating it for each iteration of the loop.

Since this count will never change during the method execution, this change make the code a bit more efficient.

Commits
-------

9ababf4 Fix `extract` method to avoid recalculating count() for each iteration.