Posts Tagged typecast

The Effects of Useless Code

Tags: , , , ,

There are a lot of ways to write C# code that has no effect. One common way is to initialize class fields to their default values: public int Value = 0;. Today we’ll go over five types of useless code and see what effect it has on the actual machine code that the CPU executes. Do IL2CPP and the C++ compiler always do the right thing? Let’s find out!

Read the rest of this article »

No Comments

Casting Questions Answered

Tags: , , , , ,

You, my dear readers, have posed many fine questions and chimed in with many excellent suggestions to my previous articles on typecasting and today I will answer them! (for newcomers to this series, read on for tips showing how to easily speed up your casts by 200x or more)

Read the rest of this article »


Typecasting: Part 3

Tags: , , , , , , , , ,

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.

Read the rest of this article »


String Conversion

Tags: , , , , , , , , , , ,

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.

Read the rest of this article »