From e979589adb47d56794909bd2e9777cd9ad46a6e9 Mon Sep 17 00:00:00 2001 From: Ben Maurer Date: Sun, 23 May 2004 20:05:04 +0000 Subject: [PATCH] 2004-05-23 Ben Maurer * MonoSymbolWriter.cs (AddLocal), etc: kill more arraylists. svn path=/trunk/mcs/; revision=27935 --- mcs/class/Mono.CSharp.Debugger/ChangeLog | 4 ++++ mcs/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/mcs/class/Mono.CSharp.Debugger/ChangeLog b/mcs/class/Mono.CSharp.Debugger/ChangeLog index 4588a6e4bfa..8156fefae9e 100644 --- a/mcs/class/Mono.CSharp.Debugger/ChangeLog +++ b/mcs/class/Mono.CSharp.Debugger/ChangeLog @@ -1,5 +1,9 @@ 2004-05-23 Ben Maurer + * MonoSymbolWriter.cs (AddLocal), etc: kill more arraylists. + +2004-05-23 Ben Maurer + * MonoSymbolTable.cs (BuildLineNumberTable): Avoid arraylist. 2004-01-16 Martin Baulig diff --git a/mcs/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs b/mcs/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs index 5c89af6566f..c13c2313532 100755 --- a/mcs/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs +++ b/mcs/class/Mono.CSharp.Debugger/MonoSymbolWriter.cs @@ -129,13 +129,16 @@ namespace Mono.CSharp.Debugger } } + static LocalVariableEntry [] locals_buf = new LocalVariableEntry [20]; + int locals_pos = 0; + public LocalVariableEntry[] Locals { get { - if (_locals == null) + if (locals_pos == 0) return new LocalVariableEntry [0]; else { - LocalVariableEntry[] retval = new LocalVariableEntry [_locals.Count]; - _locals.CopyTo (retval, 0); + LocalVariableEntry[] retval = new LocalVariableEntry [locals_pos]; + Array.Copy (locals_buf, retval, locals_pos); return retval; } } @@ -143,9 +146,12 @@ namespace Mono.CSharp.Debugger public void AddLocal (string name, FieldAttributes attributes, byte[] signature) { - if (_locals == null) - _locals = new ArrayList (); - _locals.Add (new LocalVariableEntry (name, attributes, signature, CurrentBlock.Index)); + if (locals_pos == locals_buf.Length) { + LocalVariableEntry [] t = new LocalVariableEntry [locals_buf.Length * 2 + 1]; + Array.Copy (locals_buf, t, locals_pos); + locals_buf = t; + } + locals_buf [locals_pos ++] = new LocalVariableEntry (name, attributes, signature, CurrentBlock.Index); } public MethodBase MethodBase { -- 2.11.4.GIT