From dc3d6739eef8fe59579e09f4ebb2cb33892b9d15 Mon Sep 17 00:00:00 2001 From: Christopher Hanson Date: Mon, 11 Aug 2025 14:46:02 -0500 Subject: [PATCH] 1 | Add a new benchmark mirroring Contains with only one array instantiated following feedback from SaxxonPike. It appears to have a significant impact on benchmark performance. --- Benchmarks.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Benchmarks.cs b/Benchmarks.cs index cf763c4..ca1b2a8 100644 --- a/Benchmarks.cs +++ b/Benchmarks.cs @@ -45,6 +45,13 @@ public int Contains() return keys.Count(key => new int[] { 1, 3, 7 }.Contains(key)); } + [Benchmark] + public int ContainsWithOneArray() + { + int[] containsArray = [1, 3, 7]; + return keys.Count(key => containsArray.Contains(key)); + } + [Benchmark] public int WithIf() {