Trixt0r / spriter

A Generic Java importer for Spriter animation files.

Home Page:https://brashmonkey.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Many Iterator allocations because of foreach loops.

denisk20 opened this issue · comments

Profiling on Android shows that there are many Iterator allocations which happen because of foreach loops executed on every frame. Details here, in Avoid Iterators section:
https://medium.com/google-developers/developing-for-android-ii-bb9a51f8c8b9

This is a chart for running one simple animation for just a few seconds:
image

image

Basically almost all outer circle of the chart corresponds to Iterator allocations.

Replacing foreach loops with indexed for loops in Player.update() and some other places fixes this issue:

image

There are no iterator allocations here at all.
Let me know if you're interested in a pull request for this.

Thanks for running a profiler on Android!

I would really appreciate a pull request.

@Trixt0r Pull request created, please review.