laravel/framework — pull request #3059 by Youpie (2013-12-27 15:10:20+00:00)
Title: Avoid recalculating count() for each iteration.

Since the value of `count($segments)` will never change during the method execution, cache it to avoid recalculating it for each iteration of the loop.