summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-03 15:23:13 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-03 15:23:13 +0100
commita45daf574b11a24b541cd6234ccd1d4924b28156 (patch)
tree5ba3753208d3d8f9b4c3f93273891f3595161f77 /core/src/ch/asynk/rustanddust
parentfd0e2d52975fd27e6fc72047ad2bd2d1fb21630d (diff)
downloadRustAndDust-a45daf574b11a24b541cd6234ccd1d4924b28156.zip
RustAndDust-a45daf574b11a24b541cd6234ccd1d4924b28156.tar.gz
Map5Marshal: use a static StringWriter
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
index 72e050a..3f53070 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
@@ -24,6 +24,8 @@ import ch.asynk.rustanddust.game.Engagement;
public abstract class Map5Marshal extends Map4Orders
{
+ private static StringWriter writer = new StringWriter(2048);
+
public Map5Marshal(final RustAndDust game, Texture map, SelectedTile hex)
{
super(game, map, hex);
@@ -32,8 +34,8 @@ public abstract class Map5Marshal extends Map4Orders
public String unload(Player player, Player opponent)
{
Json json = new Json(OutputType.json);
- StringWriter buffer = new StringWriter(2048);
- json.setWriter(buffer);
+ writer.getBuffer().setLength(0);
+ json.setWriter(writer);
json.writeObjectStart();
json.writeArrayStart("players");
@@ -48,8 +50,8 @@ public abstract class Map5Marshal extends Map4Orders
json.writeArrayEnd();
json.writeObjectEnd();
- buffer.flush();
- return buffer.toString();
+ writer.flush();
+ return writer.toString();
}
private void unload(Json json, Player player)