From fd776025e5fe2cfd2b2d5f7fa004ea94985b1447 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Tue, 18 Jun 2019 15:04:37 -0700 Subject: [PATCH] refactor _refreshExtensionPrimitives for clarity The previous form made it harder to see that at most one extension category is handled per call. --- src/engine/runtime.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 1a1dd23f7..ac7c7bb26 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -825,15 +825,14 @@ class Runtime extends EventEmitter { * @private */ _refreshExtensionPrimitives (extensionInfo) { - for (const categoryInfo of this._blockInfo) { - if (extensionInfo.id === categoryInfo.id) { - categoryInfo.name = maybeFormatMessage(extensionInfo.name); - categoryInfo.blocks = []; - categoryInfo.menus = []; - this._fillExtensionCategory(categoryInfo, extensionInfo); + const categoryInfo = this._blockInfo.find(info => info.id === extensionInfo.id); + if (categoryInfo) { + categoryInfo.name = maybeFormatMessage(extensionInfo.name); + categoryInfo.blocks = []; + categoryInfo.menus = []; + this._fillExtensionCategory(categoryInfo, extensionInfo); - this.emit(Runtime.BLOCKSINFO_UPDATE, categoryInfo); - } + this.emit(Runtime.BLOCKSINFO_UPDATE, categoryInfo); } }