Skip to content

Commit 4c58d62

Browse files
committed
Optimizing the material, shape and signal type manager
(let's not destroy a Dictionary every cycle)
1 parent 0be4ea2 commit 4c58d62

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Source/RunActivity/Viewer3D/Materials.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class SharedTextureManager
3737
readonly Viewer Viewer;
3838
readonly GraphicsDevice GraphicsDevice;
3939
Dictionary<string, Texture2D> Textures = new Dictionary<string, Texture2D>();
40-
Dictionary<string, bool> TextureMarks;
40+
Dictionary<string, bool> TextureMarks = new Dictionary<string, bool>();
4141

4242
[CallOnThread("Render")]
4343
internal SharedTextureManager(Viewer viewer, GraphicsDevice graphicsDevice)
@@ -198,7 +198,7 @@ public static Texture2D Get(GraphicsDevice graphicsDevice, string path)
198198

199199
public void Mark()
200200
{
201-
TextureMarks = new Dictionary<string, bool>(Textures.Count);
201+
TextureMarks.Clear();
202202
foreach (var path in Textures.Keys)
203203
TextureMarks.Add(path, false);
204204
}

Source/RunActivity/Viewer3D/Shapes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class SharedShapeManager
5151
readonly Viewer Viewer;
5252

5353
Dictionary<string, SharedShape> Shapes = new Dictionary<string, SharedShape>();
54-
Dictionary<string, bool> ShapeMarks;
54+
Dictionary<string, bool> ShapeMarks = new Dictionary<string, bool>();
5555
SharedShape EmptyShape;
5656

5757
[CallOnThread("Render")]
@@ -87,7 +87,7 @@ public SharedShape Get(string path)
8787

8888
public void Mark()
8989
{
90-
ShapeMarks = new Dictionary<string, bool>(Shapes.Count);
90+
ShapeMarks.Clear();
9191
foreach (var path in Shapes.Keys)
9292
ShapeMarks.Add(path, false);
9393
}

Source/RunActivity/Viewer3D/Signals.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ public class SignalTypeDataManager
418418
readonly Viewer Viewer;
419419

420420
Dictionary<string, SignalTypeData> SignalTypes = new Dictionary<string, SignalTypeData>();
421-
Dictionary<string, bool> SignalTypesMarks;
421+
Dictionary<string, bool> SignalTypesMarks = new Dictionary<string, bool>();
422422

423423
public SignalTypeDataManager(Viewer viewer)
424424
{
@@ -437,7 +437,7 @@ public SignalTypeData Get(SignalType mstsSignalType)
437437

438438
public void Mark()
439439
{
440-
SignalTypesMarks = new Dictionary<string, bool>(SignalTypes.Count);
440+
SignalTypesMarks.Clear();
441441
foreach (string signalTypeName in SignalTypes.Keys)
442442
{
443443
SignalTypesMarks.Add(signalTypeName, false);

0 commit comments

Comments
 (0)