diff --git a/HISTORY.md b/HISTORY.md index cf03158b..27a9b98f 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,7 @@ ### 2020-12-17 * blocks: added hook for caching variadic inputs +* blocks: refactored blockSequence() non-recursively ### 2020-12-16 * threads, objects: added dev debugging hook for counting yields diff --git a/src/blocks.js b/src/blocks.js index ff6c315f..188e1ead 100644 --- a/src/blocks.js +++ b/src/blocks.js @@ -4818,12 +4818,13 @@ CommandBlockMorph.prototype.init = function () { // CommandBlockMorph enumerating: CommandBlockMorph.prototype.blockSequence = function () { - var nb = this.nextBlock(), - result = [this]; - if (nb) { - result = result.concat(nb.blockSequence()); + var sequence = [this], + nb = this.nextBlock(); + while (nb) { + sequence.push(nb); + nb = nb.nextBlock(); } - return result; + return sequence; }; CommandBlockMorph.prototype.bottomBlock = function () {