Procházet zdrojové kódy

2004-05-14 Gonzalo Paniagua Javier <[email protected]>

	* TempFileCollection.cs: don't create a Random object on every call to
	BasePath.

svn path=/trunk/mcs/; revision=27328
Gonzalo Paniagua Javier před 21 roky
rodič
revize
db9292e4b5

+ 5 - 0
mcs/class/System/System.CodeDom.Compiler/ChangeLog

@@ -1,3 +1,8 @@
+2004-05-14  Gonzalo Paniagua Javier <[email protected]>
+
+	* TempFileCollection.cs: don't create a Random object on every call to
+	BasePath.
+
 2004-04-26  Atsushi Enomoto  <[email protected]>
 
 	* CodeGenerator.cs : delegate was output as usual class.

+ 8 - 6
mcs/class/System/System.CodeDom.Compiler/TempFileCollection.cs

@@ -4,7 +4,7 @@
 // Author:
 //	Dick Porter ([email protected])
 //
-// (C) 2003 Ximian, Inc.
+// (C) Copyright 2003 Ximian, Inc.
 //
 
 using System.IO;
@@ -17,6 +17,8 @@ namespace System.CodeDom.Compiler
 		Hashtable filehash;
 		string tempdir;
 		bool keepfiles;
+		string basepath;
+		Random rnd;
 		
 		public TempFileCollection(): this(null, false)
 		{
@@ -33,19 +35,19 @@ namespace System.CodeDom.Compiler
 			keepfiles=keepFiles;
 		}
 
-		private string basepath=null;
-		
 		public string BasePath
 		{
 			get {
 				if(basepath==null) {
-					if(tempdir==null) {
+					if (tempdir==null) {
 						/* Get the system temp dir */
 						MonoIO.GetTempPath(out tempdir);
 					}
 
-					string random=new Random().Next(10000,99999).ToString();
-					
+					if (rnd == null)
+						rnd = new Random ();
+
+					string random = rnd.Next (10000,99999).ToString ();
 					basepath = Path.Combine (tempdir, random);
 				}