diff --git a/lib/nodes.js b/lib/nodes.js index 869012e1b8..aec564895d 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1728,22 +1728,21 @@ In.prototype.children = ['object', 'array']; In.prototype.invert = NEGATE; In.prototype.compileNode = function(o) { - var isArray, obj, splat, _i, _len, _ref2; - isArray = this.array instanceof Value && this.array.isArray(); - if (isArray) { + var hasSplat, obj, _i, _len, _ref2; + if (this.array instanceof Value && this.array.isArray()) { _ref2 = this.array.base.objects; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { obj = _ref2[_i]; if (obj instanceof Splat) { - splat = obj; + hasSplat = true; + break; } } + if (!hasSplat) { + return this.compileOrTest(o); + } } - if (isArray && !splat) { - return this.compileOrTest(o); - } else { - return this.compileLoopTest(o); - } + return this.compileLoopTest(o); }; In.prototype.compileOrTest = function(o) { var cmp, cnj, i, item, ref, sub, tests, _ref2, _ref3; diff --git a/src/nodes.coffee b/src/nodes.coffee index f0f1b3e45d..520f69d22c 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -1349,12 +1349,13 @@ exports.In = class In extends Base invert: NEGATE compileNode: (o) -> - isArray = @array instanceof Value and @array.isArray() - splat = obj for obj in @array.base.objects when obj instanceof Splat if isArray - if isArray and not splat - @compileOrTest o - else - @compileLoopTest o + if @array instanceof Value and @array.isArray() + for obj in @array.base.objects when obj instanceof Splat + hasSplat = yes + break + # `compileOrTest` only if we have an array literal with no splats + return @compileOrTest o unless hasSplat + @compileLoopTest o compileOrTest: (o) -> [sub, ref] = @object.cache o, LEVEL_OP