HaxeFlixel/flixel — pull request #1256 by MSGhero (2014-08-02 20:51:41+00:00)
Title: Best performance FlxPool

Array indexing is faster than any other proposed implementation: https://github.com/MSGhero/FlxPoolTests/blob/master/tests.txt on Flash debug and Windows and Neko release.

Closes #1189.

Tested implementations using ``:
- Creating a new object (the control)
- Array methods (current implementation)
- Array indexing (this patch)
- Haxe's top-level List (shown in previous versions of the txt file)
- Custom singly-linked List

`putUnsafe + get` is faster than creating a new FlxPoint which was the concern in the original issue. `clear()`'s and `preallocate()`'s performances don't matter.

Haxe's List suffers because it just kinda sucks, docs say it's backed by multiple arrays which isn't fast. Custom linked list suffers because creating a new `Node` object is just as bad as creating a new FlxPoint.