Stephen Calender Programming Blog


Faster Rectangle Class


Nov 15

Posted: under ActionScript 3.0, ActionScript 3.0 Benchmarks, Optimization.

“An underlying theme I have discovered with Flash is that you are often better off writing your own code than trusting Adobe’s classes and functions, data structures are no exception.” – taken from my flash particle system article

After the launch and first few patches of Lego Universe, work at NetDevil has calmed down enough that I have the time and energy to explore private projects again. The current project I am working on is large and it is still in the design, test, research phase since it needs to very optimized. I saw that I was going to be doing quite a few rectangle intersects and intersection operations (the function that determines whether two rectangles overlap and the function that returns the overlapping rectangle respectively) so I took a look at the speed of Flash’s native rectangle class. I clocked Flash’s intersects function speed at over 150 simple operations (adds, multiplies, and accessing class members all count as one simple operation from my benchmarking series). I thought to myself “I can do better than that” – I was right, and I managed to write a faster intersection function too (free code).

MOAR!!!

Comments (5)