[Monodevelop-patches-list] r437 - trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Lexer

commit-watcher at mono-cvs.ximian.com commit-watcher at mono-cvs.ximian.com
Sun Jan 11 00:20:26 EST 2004


Author: benm
Date: 2004-01-11 00:20:26 -0500 (Sun, 11 Jan 2004)
New Revision: 437

Modified:
   trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Lexer/Lexer.cs
Log:
save us 35 MB while loading MCS (out of 165)

Modified: trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Lexer/Lexer.cs
===================================================================
--- trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Lexer/Lexer.cs	2004-01-11 03:51:36 UTC (rev 436)
+++ trunk/MonoDevelop/src/Libraries/SharpRefactory/src/Lexer/Lexer.cs	2004-01-11 05:20:26 UTC (rev 437)
@@ -328,19 +328,28 @@
 			
 			return new Token(Tokens.EOF, col, line, String.Empty);
 		}
+		
+		const int max_id_size = 512;
+		char [] id_builder = new char [max_id_size];
 		
 		string ReadIdent(char ch)
 		{
-			StringBuilder s = new StringBuilder(ch.ToString());
+			int pos = 0;
+			
+			id_builder [pos ++] = ch;
 			++col;
-			while (!reader.Eos() && (Char.IsLetterOrDigit(ch = reader.GetNext()) || ch == '_')) {
-				s.Append(ch.ToString());
+			while (!reader.Eos() && (Char.IsLetterOrDigit(ch = reader.GetNext()) || ch == '_')) {
+				if (pos == max_id_size) {
+					errors.Error(col, line, "identifier too long");
+				}
+				
+				id_builder [pos ++] = ch;
 				++col;
 			}
 			if (!reader.Eos()) {
 				reader.UnGet();
 			}
-			return s.ToString();
+			return new String (id_builder, 0, pos);
 		}
 		
 		Token ReadDigit(char ch, int x)




More information about the Monodevelop-patches-list mailing list