ByteArray Secrets

Tags: , , , ,

The ByteArray class is not as straightforward as you might think. In certain situations, it has surprising, undocumented functionality. Today’s article goes into some of these strange behaviors so you’ll get a better handle on exactly what’s going on behind the scenes.

Read the rest of this article »

2 Comments

Optimize Algorithms and Data Structures First

Tags: , , , ,

Today’s article is both a reminder to optimize your algorithms and data structures before your code and a demonstration of the payoff you’ll get by doing so. By choosing the most effective algorithm and data structure to solve your problem you’ll reap huge rewards in performance. A 10x, 100x, or even bigger boost is easily attainable.

Read the rest of this article »

No Comments

Four Ways to Clean Master Strings

Tags: , , , ,

When I first wrote about master strings I proposed a function that would help to trim them down and potentially save a lot of memory. However, that method still resulted in a string with a master string one longer than it. Ideally, we’d have no master string at all. Since then, three astute readers chimed in with alternate solutions to the problem. Today I put try all three out to see which method does the best job of cleaning master strings.

Read the rest of this article »

4 Comments

Recursion vs. Iteration

Tags: , , ,

Function calls in Flash are notoriously slow. Recursive algorithms require lots of function calls by definition. So are iterative versions faster? Today’s article explores whether or not it’s worth converting your recursive algorithm into an iterative one.

Read the rest of this article »

9 Comments

Int Keys: Object vs. Dictionary vs. Array vs. Vector

Tags: , , , , , , , ,

Given that Object and Dictionary can have int keys and that int keys are faster than String keys, a natural performance test follows: which class is fastest at reading from and writing to those int keys? Is there a difference between the four Vector classes? Today’s article performs just that test and comes up with the answers.

Read the rest of this article »

6 Comments

String Keys vs. Int Keys

Tags: , , , , , ,

Now that we know you can use int keys with Object, it’s time to test whether or not this is any faster than String keys. Today’s article does just that and also tests int and String keys with Dictionary.

Read the rest of this article »

5 Comments

Using Non-String Keys with Object

Tags: , , , ,

Pop quiz: what’s the difference between an Object and a Dictionary? If you said “Dictionary can have non-String keys”, you bought into a common myth. Today’s article shows the cases where the lowly Object class will use non-String keys whether you like it or not. Read on for the details.

Read the rest of this article »

6 Comments

5x Faster For-In Loops

Tags: , , ,

I’ve recently been notified of a way to dramatically speed up for-in loops. I’ve tested this method out and indeed there is a 5x speedup. Employing the technique is also really easy. Unfortunately, the speedup is sometimes an illusion. Read on to learn a little more about for-in loops and how you could potentially speed yours up by 5x.

Read the rest of this article »

9 Comments

XMLDocument: The Faster Legacy XML Option

Tags: , ,

Sometimes the old, legacy option is faster than the new one you’re supposed to use. That happens to be the case with XML in Flash: XMLDocument is quicker than XML. Today’s article tests its performance to figure out just how much faster it is and if it can keep up with plain Object and typed class instances.

Read the rest of this article »

1 Comment

XML E4X Expression Performance

Tags: ,

If you deal with XML documents, you probably appreciate AS3′s support for the E4X operators. These make it really easy to access the XML class like any old object with the .x (dot) operator as well as XML-specific operators like ..x for descendants and @x for attributes. Even fancier, there’s support for arbitrary expressions like .(@id == "123"). With all this convenience we should wonder- how slow are the E4X expressions?

Read the rest of this article »

1 Comment