Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement ObjectPool design pattern for FlxQuadTree #230

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

greysondn
Copy link

This is what I refer to as the @moly fixes, the changes requested more than a year ago in #107 and first attempted to patch in #169.

The major difference between now and back at #169 is... Well, moly's ObjectPool is a generic implementation of the design pattern, and a fairly elegant one at that. However, because this is Flixel, it's been renamed FlxObjectPool; and because of the organizational changes, I made it a public class and stuck in the util package.

Mostly, I referred to the original commit's changes. There are some small differences - spacing, I guess I was OCD about curly braces at that time, etcetera - but otherwise the code is the same.

I have given this a once over test. Collisions still work and it compiles. That's all I can guarantee. I'm still dealing with my own problems with the current codebase that impede more exhaustive tests. I would recommend some testing, mostly to make sure that memory doesn't leak. It should actually rein in past memory problems, as well as give some speedup to physics calculations, but no promises.

For what it's worth, the first time this set of changes was attempted, it did result in significant speedups to the code's execution and was fine. It is only caution requesting testing.

I'm available for questioning and for changes needed in the pull.

@@ -262,16 +275,13 @@ package flixel.physics
if(_headA != null)
_headA.destroy();
_headA = null;
if(_tailA != null)
_tailA.destroy();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_headA and _tailA point to the same object. We can't call destroy() on it twice. See the modified implementation in FlxList for this commit.

@greysondn
Copy link
Author

Erps. Didn't realize it'd show up in the pull XD The commentary covers the only part I had to trace code to understand, on the assumption that others may find it unclear or unintuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant