Posts Tagged if

C++ For C# Developers: Part 6 – Control Flow

Tags: , , , , , , , , ,

Let’s continue the series with another nuts-and-bolts topic: control flow. The Venn diagram is largely overlap here, but both C# and C++ have their own unique features and some of the features in common have important differences between the two languages. Read on for the nitty-gritty!

Read the rest of this article »

6 Comments

IL2CPP Output for C# 7.3: Pattern Matching

Tags: , , , ,

Last week we started exploring the new features of C# 7.3 in Unity 2018.3 by delving into tuples. This week we’ll continue and look at pattern matching. Read on to see how the many forms of pattern matching are actually implemented by IL2CPP!

Read the rest of this article »

3 Comments

If-Else is Really Expensive

Tags: , , ,

Sometimes a tiny amount of code costs a huge amount of performance. This is especially true of built-in language features, which many programmers assume to be extremely cheap if not free. Today we’ll look at if and see just how much performance it can cost your app. Read on to see!

Read the rest of this article »

7 Comments

Delegates As Function Pointers: Performance Boost?

Tags: , , ,

C# delegates can be used like function pointers. Assign it once and you don’t have to use an if over and over. But is the overhead of the delegate worth it? Today’s article puts it to the test to see if this a valid performance boost versus just using an if over and over. Read on to see if a delegate is worth your time.

Read the rest of this article »

4 Comments

From AS3 to C#, Part 17: Conditionals, Exceptions, and Iterators

Tags: , , , , , , , , ,

Continuing the series on C# syntax, today we’ll look at the differences an AS3 programmer can expect to encounter when using conditionals (if/else, switch/case/break/goto) and exceptions (try/catch/finally/throw). We’ll also look at iterators, an all-new category for AS3 programmers that empowers us to both iterate however we want and to write coroutines, a kind of lightweight pseudo-thread.

Read the rest of this article »

4 Comments

The Cost of If-Else

Tags: , ,

The if-else keyword is not free. So, how expensive is it? Today’s article finds out.

Read the rest of this article »

7 Comments

ASC 2.0 Conditionals Performance

Tags: , , , , , , ,

Surprisingly, some interesting things have been happening with conditionals like if-else in AS3. First, a brand new AS3 compiler—ASC 2.0—has been released with the promise that it’ll generate more efficient bytecode. Second, some readers have pointed out the existence of a new (to me) technique: the “if-else tree”. Today’s article takes a look at just what that is and tests it against the classic options: if-else, the ternary (? :) operator, and the switch statement. Which will be fastest?

Read the rest of this article »

19 Comments

Advanced break and continue Statements

Tags: , , , ,

There’s more to AS3’s break and continue statements than you might think. Chances are, you’ve used them to skip to after a loop (break) and skip the current loop iteration (continue), but they can do so much more. Today’s article will cover some of the advanced ways to use the break and continue statements in AS3 resulting in nicer—and maybe even faster—code.

Read the rest of this article »

15 Comments

Redundant Code

Tags: , , ,

Why do I see so many AS3 programmers writing so much redundant code? Are you one of them? Today’s tips may save you a lot of typing. It may even save you a lot of SWF size.

Read the rest of this article »

20 Comments

Conditionals Performance Revisited

Tags: , , , , , ,

Today I’m revisiting an article I wrote last August about conditionals: if-else chains, ternary (? :) operators, and switch statements. In that article I showed that if-else chains are about as fast as ternary operators and that both of them are 10-15% faster than switch statements. Today we’ll take a look at how those conditionals scale beyond just the few cases in the last article.

Read the rest of this article »

18 Comments