Posts Tagged operator

C++ For C# Developers: Part 34 – Fold Expressions and Elaborated Type Specifiers

Tags: , , ,

Today we’ll cover a couple of more minor features that don’t have C# equivalents: fold expressions and elaborated type specifiers. Though they are small, they can be quite useful!

Read the rest of this article »

No Comments

C++ For C# Developers: Part 11 – Struct Functions

Tags: , , ,

Now that we’ve covered the basics of structs, let’s add functions to them! Today we’ll explore member functions and overloaded operators.

Read the rest of this article »

3 Comments

Enum Arithmetic and Operators

Tags: , ,

C# enum types are an easy and efficient way to make an integer type without all the overhead of something like a class or even a struct. They’re basically a synonym for an integer type like byte or int. However, that “basically” hides a lot of details that affect the way you can work with them. Today’s article explores the arithmetic and operators you are and aren’t allowed to use when you opt for an enum over an int so you’ll have a better understanding of how and how not to use them.

Read the rest of this article »

No Comments

From AS3 to C#, Part 15: Loops, Casts, and Operators

Tags: , ,

As with types and variables, there is a lot of subtlety in the differences between AS3 and C# when it comes to loops, casts, and operators. As core parts of the language, it’s important that we know all the little details of our most fundamental tools. Read on to learn what they have in common, what new operators C# offers, and what operators C# doesn’t have.

Read the rest of this article »

5 Comments

XML E4X Operators vs. XML Class Methods

Tags: , , , ,

We know that the XML E4X operators are an 10x slower than plain Object, but how slow are they compared to the XML class’ methods like elements() and attributes? Today’s article finds that out.

Read the rest of this article »

5 Comments

XML Operator Speed

Tags: , , , , , ,

AS3 has always had great support for XML built right into the language, but how fast is it? Today’s article compares the performance of operators that work on XML objects like .@x, .x, ..x, and ["x"] against their equivalents in plain Object instances and typed class instances. Just how slow are the XML operators? Read on to find out.

Read the rest of this article »

4 Comments

Converting Numbers to Ints

Tags: , , , , , ,

This is an extremely common task: converting a Number to an int. There are a lot of ways to do it, but which is fastest in AS3? Today we’ll look at a performance test app that attempts to find the fastest way to accomplish this. The answer just may surprise you!

Read the rest of this article »

14 Comments

Checking Class Inheritance

Tags: , , , , ,

I recently received a tip about a thread discussing an interesting problem: how to tell if one Class object represents a class that subclasses another Class object. If you had an instance of the class, you could simply use the is or instanceof keywords, but that won’t do here. Today’s article shows how to solve this tricky problem.

Read the rest of this article »

20 Comments

Faster Logic With Bitwise Operators

Tags: , , , , ,

Logical operators are necessary in every app, so it’s unfortunate that they are so slow in AS3. That’s why I was happy to see a potential alternative in a recent comment by Skyboy. Today’s article shows you how to do logic faster by avoiding logical operators (e.g. &&) and using their bitwise (e.g. &) operator counterparts instead.

Read the rest of this article »

25 Comments

Indexing Fields Is Really Slow

Tags: , , , , , , , , ,

One of the very nice features of AS3 (and AS2 and JavaScript for that matter) is that you can dynamically access the fields of any object. This leads to much more dynamic code since you no longer need to know what field to access at compile time. As we’ve often seen with other dynamic features, this can come at a steep cost in terms of performance. Today we’ll see just how slow accessing fields this way is to get a good idea of just how much performance we give up when using this feature.

Read the rest of this article »

10 Comments