From e70781ef0ffb0df80bee3ee8e66beb74bfec5639 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 31 Mar 2023 21:25:07 +0100 Subject: [PATCH] =?UTF-8?q?perf:=20remove=20redundant=206k=20=C2=B1=201=20?= =?UTF-8?q?check=20in=20IsPrime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No integers >3 satisfy the condition of being odd AND not being a multiple of 3 (as checked above) AND not being in the form 6k ± 1. This condition never evaluates to true, and so the return is never reached and was preventing this method from hitting 100% code coverage. --- X10D/src/Math/Int64Extensions.cs | 5 ----- X10D/src/Math/UInt64Extensions.cs | 5 ----- 2 files changed, 10 deletions(-) diff --git a/X10D/src/Math/Int64Extensions.cs b/X10D/src/Math/Int64Extensions.cs index 94fb8d7cd..8d76498a0 100644 --- a/X10D/src/Math/Int64Extensions.cs +++ b/X10D/src/Math/Int64Extensions.cs @@ -148,11 +148,6 @@ public static bool IsPrime(this long value) return false; } - if ((value + 1) % 6 != 0 && (value - 1) % 6 != 0) - { - return false; - } - for (var iterator = 5L; iterator * iterator <= value; iterator += 6) { if (value % iterator == 0 || value % (iterator + 2) == 0) diff --git a/X10D/src/Math/UInt64Extensions.cs b/X10D/src/Math/UInt64Extensions.cs index ca5c2f518..818a97501 100644 --- a/X10D/src/Math/UInt64Extensions.cs +++ b/X10D/src/Math/UInt64Extensions.cs @@ -125,11 +125,6 @@ public static bool IsPrime(this ulong value) return false; } - if ((value + 1) % 6 != 0 && (value - 1) % 6 != 0) - { - return false; - } - for (var iterator = 5UL; iterator * iterator <= value; iterator += 6) { if (value % iterator == 0 || value % (iterator + 2) == 0)