Today’s article is about an unintuitive-yet-simple optimization you can use to hugely increase the speed of reading from Array
, Vector
, Dictionary
, Object
, and dynamic
classes. Need I say more? Read on for this amazing speedup!
Posts Tagged typecast
Today’s article is a followup to an article (Cast Speed, itself a followup to Two Types of Casts) from September that continues to gather comments. Sharp-eyed reader fastas3 brought up a good point that warranted some further investigation into the topic. So today we’ll be taking yet-another look at typecasting in AS3 to try to unravel some of its strange mysteries.
One of the first articles I wrote for this site covered the two types of casts available to the AS3 programmer. In that article I covered the syntax of the two as well as some of the quirks. Today I’ll cover the performance differences between them.
As a followup to the previous article about object creation and a comment about an alternate object creation strategy, today’s article will expand the coverage of object creation. I will also discuss the performance (and generated bytecode) for creating non-empty objects to see if there are any redeeming factors to the “curly braces” (o = {}
) approach.
The differences between Vector and Array have been quite interesting since Vector was introduced in Flash Player 10. Until just recently I didn’t know that there was special syntax for declaring a Vector akin to Array's special a = [1,2,3,4,5] trick. This got me thinking about the various ways one can declare a Vector and, of course, how they’re implemented in bytecode and what the speed differences, if any, are. Read on for some nitty gritty about how you declare Vectors in AS3.
It struck me recently that there are a lot of ways to convert variables of many types to a the String type. The ease of doing this is one of AS3’s strengths over languages where it’s error-prone, possibly insecure, and just plain difficult. The C language is the most obvious example of this and, since then, seemingly every language has enshrined string conversion in ways ranging from global String() functions (AS3) that take any variable to adding toString() to the base Object type (Java, AS3, others). AS3 seems to have chosen “all of the above” and there are now many ways to convert to a string. Below I’ll look at them from a performance standpoint and see if the everyday, run-of-the-mill boring string conversion can be improved by choosing one option over another.
The chief quality of Vectors is that they hold a single type of object. This is why they are sometimes called “typed arrays”. So what would happen if you wanted to convert an array of mixed-type objects into a vector?
Vectors– typed arrays in AS3– are much quicker than arrays and therefore very useful. There are many times where you end up with arrays though and need to convert them into vectors for the bulk of your using that data. This article is about that process.