[Mono-devel-list] reading speed of compiler
Martin Waldenburg
Martin.Waldenburg at t-online.de
Sat Mar 29 09:53:23 EST 2003
Hi,
Following a little modification, that will enhance
the reading speed of the compiler by 3000%.
Actualy the speed could be increased a few times more,
but that will require a redesign of the tokenizer.
Martin
***************************************************************************************
static void tokenize_file (SourceFile file)
{
Stream FS;
Stream input;
try {
FS = File.OpenRead (file.Name);
byte[] ByteBuffer = new byte[FS.Length];
FS.Read(ByteBuffer, 0, (int)FS.Length);
input = new MemoryStream(ByteBuffer);
} catch {
Report.Error (2001, "Source file '" + file.Name + "' could
not be opened");
return;
}
using (input){
StreamReader reader = new StreamReader (input, encoding,
using_default_encoder);
Tokenizer lexer = new Tokenizer (reader, file, defines);
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Token.EOF){
Location l = lexer.Location;
tokens++;
if (token == Token.ERROR)
errors++;
}
Console.WriteLine ("Tokenized: " + tokens + " found " +
errors + " errors");
}
return;
}
More information about the Mono-devel-list
mailing list