From c7b597539215bb7d513dbc44a6ca3ee88a363e86 Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Sun, 16 Jun 2024 14:34:12 +0200 Subject: [PATCH] rewrote spawn code to be allocation-free --- Examples/Textures/Bunnymark.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Examples/Textures/Bunnymark.cs b/Examples/Textures/Bunnymark.cs index 77bdc9c..364a4d5 100644 --- a/Examples/Textures/Bunnymark.cs +++ b/Examples/Textures/Bunnymark.cs @@ -68,12 +68,11 @@ public static class Bunnymark if (IsMouseButtonDown(MouseButton.Left) && bunniesCount < MaxBunnies) { // Add a range of new bunnies - Enumerable.Range(0, BunnyIncrement) - .Select(_ => new Bunny()) - .ToArray() - .CopyTo(bunnies[bunniesCount..]); - - bunniesCount+= BunnyIncrement; + foreach (ref var bunny in bunnies[bunniesCount..(bunniesCount+BunnyIncrement)]) + { + bunny = new(); + } + bunniesCount += BunnyIncrement; } else if (IsMouseButtonDown(MouseButton.Right)) {