Posts Tagged linq

LINQ-Style Generic Algorithms for Burst

Tags: , , ,

We’ve seen how to create powerful, Burst-compatible generic algorithms already, but today we’ll take another approach to generic algorithms and implement them in the style of C#’s LINQ. Along the way, we’ll tackle a new challenge by implementing a generic algorithm that allocates a new collection.

Read the rest of this article »

2 Comments

5 Common Misuses of Collections

Tags: , , , , , , ,

Collection types like List<T> and Dictionary<TKey, TValue> are fundamental tools in C#. Sadly, I keep seeing the same misuses of them in codebase after codebase. Today we’ll look at the top 5 problems and learn how to easily avoid them!

Read the rest of this article »

13 Comments

Just How Much Garbage Does LINQ Create?

Tags: , , ,

LINQ’s CPU performance is quite poor, but how is it with memory? Does every LINQ function always create tons of garbage for the GC to collect, or are there exceptions that aren’t so bad? Today’s article tests out lots of LINQ functions to find out!

Read the rest of this article »

6 Comments

LINQ Performance Update

Tags: , ,

It’s been over three years since the last article on LINQ performance. That was all the way back in the Unity 5.0 days using Mono as a scripting backend. Today we’ll update that article’s test with Unity 2018.1 and IL2CPP to see how LINQ fares these days. Is it any better? Read on to find out!

Read the rest of this article »

3 Comments

LINQ Extensions: Part 1

Tags: , ,

One of C#’s most unique features is its SQL-style LINQ syntax. It’s a powerful and expressive way to treat data structures like a database and perform all kinds of actions on them. LINQ can also be used without the SQL-style syntax via various extension methods of IEnumerable<T> defined in the System.Linq namespace. Due to C#’s extension method feature, we’re free to add on our own LINQ-style functions to extend its power. Today’s article introduces some extension methods to do just that. Read on for the source code and power up your LINQ!

Read the rest of this article »

No Comments

The Magic of LINQ Expressions

Tags: , , ,

LINQ expressions aren’t the same thing as LINQ queries. They’re more like reflection for the syntax of C# itself. It’s a fascinating—and powerful—area of the language and I’ll be exploring it a little in today’s article.

Read the rest of this article »

9 Comments

Basic LINQ Performance

Tags: , , ,

SQL-style LINQ queries are a concise, readable way of performing various tasks dealing with all kinds of collections. Surely all that convenience comes with a performance cost to it. How bad do you think it is? Today we’ll look at the cost of some basic LINQ queries (Where, Select) versus the equivalent non-LINQ code. We’ll also see how much slower both of them are compared to manually-written, traditional code that does away with all the flexibility. Read on to see the results!

Read the rest of this article »

2 Comments

From AS3 to C#, Part 19: SQL-Style Queries With LINQ

Tags:

The series continues today by looking at C#’s SQL-style queries called LINQ. These don’t run on a database, but rather query in-memory objects like arrays. Read on to learn about this powerful tool for writing extremely concise, readable code.

Read the rest of this article »

2 Comments