From 41a166fb0ea7ccd4dcc79741e4c55a6d2513f673 Mon Sep 17 00:00:00 2001 From: cyantree - Christoph Schreiber Date: Fri, 3 Jul 2020 11:42:18 +0200 Subject: [PATCH] Rework check in `isValidShortKeyInternal()` to being an early return --- src/js/game/shape_definition.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/js/game/shape_definition.js b/src/js/game/shape_definition.js index ec8d1cef..a521930f 100644 --- a/src/js/game/shape_definition.js +++ b/src/js/game/shape_definition.js @@ -177,6 +177,11 @@ export class ShapeDefinition extends BasicSerializableObject { */ static isValidShortKeyInternal(key) { const sourceLayers = key.split(":"); + + if (sourceLayers.length === 0 || sourceLayers.length > 4) { + return false; + } + let layers = []; for (let i = 0; i < sourceLayers.length; ++i) { const text = sourceLayers[i]; @@ -222,10 +227,6 @@ export class ShapeDefinition extends BasicSerializableObject { layers.push(quads); } - if (layers.length === 0 || layers.length > 4) { - return false; - } - return true; }