From 0f693938ee166341888b01e95fde87ac52a0546f Mon Sep 17 00:00:00 2001 From: FatCatX Date: Tue, 15 Jun 2021 21:45:05 -0700 Subject: [PATCH] Update blueprint.js Only create SerializerInternal when needed. --- src/js/game/blueprint.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/game/blueprint.js b/src/js/game/blueprint.js index 23686fa8..fe14175f 100644 --- a/src/js/game/blueprint.js +++ b/src/js/game/blueprint.js @@ -16,7 +16,6 @@ export class Blueprint { */ constructor(entities) { this.entities = entities; - this.serializer = new SerializerInternal(); } /** @@ -34,7 +33,7 @@ export class Blueprint { * Serialize */ serialize() { - let data = this.serializer.serializeEntityArray(this.entities); + let data = new SerializerInternal().serializeEntityArray(this.entities); // Remove unneeded fields for (let i = 0; i < data.length; ++i) { const entry = data[i]; @@ -58,6 +57,8 @@ export class Blueprint { if (!Array.isArray(json)) { return; } + + const serializer = new SerializerInternal(); /** @type {Array} */ const entityArray = []; for (let i = 0; i < json.length; ++i) { @@ -70,7 +71,7 @@ export class Blueprint { if (staticData.code == undefined || staticData.origin == undefined) { return; } - const result = new SerializerInternal().deserializeEntity(root, value); + const result = serializer.deserializeEntity(root, value); if (typeof result === "string") { throw new Error(result); }