Skip to main content
improve wording, encourage asker to use a profiler
Source Link

ThereYou should start with a profiler. Having said that, there is one easy optimization you can make without a lot of code changes.

Change the following line in LoadSpriteSheets from
List<SpriteSheet> sheets = new List<SpriteSheet>();
to
List<SpriteSheet> sheets = new List<SpriteSheet>(tmxMap.Tilesets.Count);

The amount of elements in the list is known in advance so you can avoid the cost of repeatedly resizing the container.

There is one easy optimization you can make without a lot of code changes.

Change the following line in LoadSpriteSheets from
List<SpriteSheet> sheets = new List<SpriteSheet>();
to
List<SpriteSheet> sheets = new List<SpriteSheet>(tmxMap.Tilesets.Count);

The amount of elements in the list is known in advance so you can avoid the cost of repeatedly resizing the container.

You should start with a profiler. Having said that, there is one easy optimization you can make without a lot of code changes.

Change the following line in LoadSpriteSheets from
List<SpriteSheet> sheets = new List<SpriteSheet>();
to
List<SpriteSheet> sheets = new List<SpriteSheet>(tmxMap.Tilesets.Count);

The amount of elements in the list is known in advance so you can avoid the cost of repeatedly resizing the container.

Source Link

There is one easy optimization you can make without a lot of code changes.

Change the following line in LoadSpriteSheets from
List<SpriteSheet> sheets = new List<SpriteSheet>();
to
List<SpriteSheet> sheets = new List<SpriteSheet>(tmxMap.Tilesets.Count);

The amount of elements in the list is known in advance so you can avoid the cost of repeatedly resizing the container.