[gbrainy] Use shorts instead of inits to store the primes list



commit f27b8d4675575dadb7db7f4cd952c6aaa74c3aec
Author: Jordi Mas <jmas softcatala org>
Date:   Sun Apr 18 22:26:01 2010 +0200

    Use shorts instead of inits to store the primes list

 src/Games/Calculation/CalculationPrimes.cs |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/Games/Calculation/CalculationPrimes.cs b/src/Games/Calculation/CalculationPrimes.cs
index 7d177d9..8268e5c 100644
--- a/src/Games/Calculation/CalculationPrimes.cs
+++ b/src/Games/Calculation/CalculationPrimes.cs
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Jordi Mas i Hernàndez <jmas softcatala org>
+ * Copyright (C) 2009-2010 Jordi Mas i Hernàndez <jmas softcatala org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -32,10 +32,10 @@ namespace gbrainy.Games.Calculation
 		const int total_primes = 1129;
 		const int total_nums = 5;
 		double width_box, height_box;
-		int max;
+		short max;
 		bool div3;	
 		int []numbers;
-		int []primes = new int []	
+		short []primes = new short []	
 		{
 			2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 
 			37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 
@@ -237,11 +237,12 @@ namespace gbrainy.Games.Calculation
 			gr.ShowPangoText (Catalog.GetString ("Numbers"));
 		}
 	
-		int GenerateNonPrime ()
+		short GenerateNonPrime ()
 		{
-			int num;
+			short num;
 			while (true) {
-				num = 100 + random.Next (max - 100);
+				// Max value is a short
+				num = (short) (100 + (random.Next (max - 100)));
 
 				if (num % 2 == 0)
 					continue;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]