- optimized simplify()

Mon, 30 Jun 2014 05:53:14 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 30 Jun 2014 05:53:14 +0300
changeset 817
cee9f0ecac66
parent 816
9adb822de7b9
child 818
748ba8818af8

- optimized simplify()

src/miscallenous.cc file | annotate | diff | comparison | revisions
--- a/src/miscallenous.cc	Mon Jun 30 05:52:10 2014 +0300
+++ b/src/miscallenous.cc	Mon Jun 30 05:53:14 2014 +0300
@@ -146,12 +146,12 @@
 	{
 		repeat = false;
 
-		for (int x = 0; x < NUM_PRIMES; x++)
+		for (int x = 0; x < countof (primes); x++)
 		{
-			const int prime = g_primes[NUM_PRIMES - x - 1];
+			int const prime = primes[x];
 
-			if (numer <= prime || denom <= prime)
-				continue;
+			if (numer < prime && denom < prime)
+				break;
 
 			if ((numer % prime == 0) && (denom % prime == 0))
 			{
@@ -161,8 +161,7 @@
 				break;
 			}
 		}
-	}
-	while (repeat);
+	} while (repeat);
 }
 
 // =============================================================================

mercurial