From 4b64df222a1a4228a73e9dfd5abc8c82a7662677 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 13 Jun 2018 10:09:22 -0400 Subject: [PATCH] Hoist target list assignment to simplify code. --- src/virtual-machine.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 5e77adebf..4ff368faa 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -1041,11 +1041,11 @@ class VirtualMachine extends EventEmitter { * @returns {boolean} Whether a target was reordered. */ reorderTarget (targetIndex, newIndex) { - targetIndex = MathUtil.clamp(targetIndex, 0, this.runtime.targets.length - 1); - newIndex = MathUtil.clamp(newIndex, 0, this.runtime.targets.length - 1); - if (targetIndex === newIndex) return false; - const target = this.runtime.targets[targetIndex]; let targets = this.runtime.targets; + targetIndex = MathUtil.clamp(targetIndex, 0, targets.length - 1); + newIndex = MathUtil.clamp(newIndex, 0, targets.length - 1); + if (targetIndex === newIndex) return false; + const target = targets[targetIndex]; targets = targets.slice(0, targetIndex).concat(targets.slice(targetIndex + 1)); targets.splice(newIndex, 0, target); this.runtime.targets = targets;