1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:28:48 +00:00

perf: remove redundant 6k ± 1 check in IsPrime

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.
This commit is contained in:
Oliver Booth 2023-03-31 21:25:07 +01:00
parent c8ccb1deb8
commit e70781ef0f
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
2 changed files with 0 additions and 10 deletions

View File

@ -148,11 +148,6 @@ public static class Int64Extensions
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)

View File

@ -125,11 +125,6 @@ public static class UInt64Extensions
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)