gcode-mirror / ai-contest

Automatically exported from code.google.com/p/ai-contest
0 stars 1 forks source link

Game.java spends way too much time/memory building the gamePlayback string #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run a game with lots of fleets using PlayGame.jar
2. It is really slow
3. Because if you keep doing string += "some stuff"; in Java, it has to make a 
new copy of the _entire string_.

Attached is a patch which uses StringBuilder to build the gamePlayback string.  
This engine is much, much, much faster.  Warning: the output appears to be 
correct with a cursory investigation, but I'm not totally sure I haven't broken 
it.

Original issue reported on code.google.com by andy.sloane on 8 Sep 2010 at 7:19

Attachments:

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/ai-contest/source/branch?spec=issue77 for code review 
of this patch

Original comment by andy.sloane on 9 Sep 2010 at 8:27

GoogleCodeExporter commented 9 years ago
I  a1k0n fixed this issue. 

Original comment by danie...@gmail.com on 10 Sep 2010 at 10:43