From 754c769513477a9a4cefafba23f2036307e74381 Mon Sep 17 00:00:00 2001 From: codeimp <codeimp@e0d998f2-2e9b-42fe-843d-47128df60a06> Date: Thu, 18 Jun 2009 14:23:33 +0000 Subject: [PATCH] @ little optimization in map data allocating when reading from stream/file --- Source/Core/IO/DoomMapSetIO.cs | 8 ++++---- Source/Core/IO/HexenMapSetIO.cs | 8 ++++---- Source/Core/IO/UniversalStreamReader.cs | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/Core/IO/DoomMapSetIO.cs b/Source/Core/IO/DoomMapSetIO.cs index 56b62f8e2..01f531034 100644 --- a/Source/Core/IO/DoomMapSetIO.cs +++ b/Source/Core/IO/DoomMapSetIO.cs @@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.IO reader = new BinaryReader(mem); // Read items from the lump - map.SetCapacity(0, 0, 0, 0, num); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + num); for(i = 0; i < num; i++) { // Read properties from stream @@ -179,7 +179,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(num); // Read items from the lump - map.SetCapacity(num, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + num, 0, 0, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -224,7 +224,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(num); // Read items from the lump - map.SetCapacity(0, 0, 0, num, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + num, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -282,7 +282,7 @@ namespace CodeImp.DoomBuilder.IO readside = new BinaryReader(sidedefsmem); // Read items from the lump - map.SetCapacity(0, num, numsides, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + num, map.Sidedefs.Count + numsides, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream diff --git a/Source/Core/IO/HexenMapSetIO.cs b/Source/Core/IO/HexenMapSetIO.cs index b2a882164..2581b1c8a 100644 --- a/Source/Core/IO/HexenMapSetIO.cs +++ b/Source/Core/IO/HexenMapSetIO.cs @@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.IO reader = new BinaryReader(mem); // Read items from the lump - map.SetCapacity(0, 0, 0, 0, num); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + num); for(i = 0; i < num; i++) { // Read properties from stream @@ -189,7 +189,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(num); // Read items from the lump - map.SetCapacity(num, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + num, 0, 0, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -234,7 +234,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(num); // Read items from the lump - map.SetCapacity(0, 0, 0, num, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + num, 0); for(i = 0; i < num; i++) { // Read properties from stream @@ -293,7 +293,7 @@ namespace CodeImp.DoomBuilder.IO readside = new BinaryReader(sidedefsmem); // Read items from the lump - map.SetCapacity(0, num, numsides, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + num, map.Sidedefs.Count + numsides, 0, 0); for(i = 0; i < num; i++) { // Read properties from stream diff --git a/Source/Core/IO/UniversalStreamReader.cs b/Source/Core/IO/UniversalStreamReader.cs index e4953bc93..a159a19a4 100644 --- a/Source/Core/IO/UniversalStreamReader.cs +++ b/Source/Core/IO/UniversalStreamReader.cs @@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.IO List<UniversalCollection> collections = GetNamedCollections(textmap.Root, "thing"); // Go for all collections - map.SetCapacity(0, 0, 0, 0, collections.Count); + map.SetCapacity(0, 0, 0, 0, map.Things.Count + collections.Count); for(int i = 0; i < collections.Count; i++) { // Read fields @@ -198,7 +198,7 @@ namespace CodeImp.DoomBuilder.IO List<UniversalCollection> sidescolls = GetNamedCollections(textmap.Root, "sidedef"); // Go for all lines - map.SetCapacity(0, linescolls.Count, sidescolls.Count, 0, 0); + map.SetCapacity(0, map.Linedefs.Count + linescolls.Count, map.Sidedefs.Count + sidescolls.Count, 0, 0); for(int i = 0; i < linescolls.Count; i++) { // Read fields @@ -313,7 +313,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Sector>(collections.Count); // Go for all collections - map.SetCapacity(0, 0, 0, collections.Count, 0); + map.SetCapacity(0, 0, 0, map.Sectors.Count + collections.Count, 0); for(int i = 0; i < collections.Count; i++) { // Read fields @@ -354,7 +354,7 @@ namespace CodeImp.DoomBuilder.IO link = new Dictionary<int, Vertex>(collections.Count); // Go for all collections - map.SetCapacity(collections.Count, 0, 0, 0, 0); + map.SetCapacity(map.Vertices.Count + collections.Count, 0, 0, 0, 0); for(int i = 0; i < collections.Count; i++) { // Read fields -- GitLab