implemented your suggestion on a different branch and did some initial profiling tests
https://github.com/staabm/composer/commit/6bdea1f01a8109c839bb70f4c57e27a50d0dbae8

it looks like, that all in all it got slower and memory consumption nearly doubled
`Memory usage: 32.2MB (peak: 72.26MB), time: 8.29s`

It seems worth also in some of the other places to use this technique. Also having it in a separate function makes the GC happy it seems. The additional function call does not cost that much.

Tell me which approach you like more and I will will provide the PR as you like.