From ecd4722b7ce64fbef41d0240d972c76a07d5d127 Mon Sep 17 00:00:00 2001 From: satyr Date: Tue, 26 Oct 2010 13:33:03 +0900 Subject: [PATCH] removed a redundancy in splatted assignment --- lib/nodes.js | 4 ++-- src/nodes.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nodes.js b/lib/nodes.js index bae11572..2b51d292 100644 --- a/lib/nodes.js +++ b/lib/nodes.js @@ -1169,8 +1169,8 @@ }; Splat.prototype.compileValue = function(o, name, index, trailings) { var trail; - trail = trailings ? ", " + name + ".length - " + trailings : ''; - return "" + (utility('slice')) + ".call(" + name + ", " + index + trail + ")"; + trail = trailings ? ', -' + trailings : ''; + return utility('slice') + (".call(" + name + ", " + index + trail + ")"); }; Splat.compileSplattedArray = function(list, o) { var _len, arg, args, code, end, i, prev; diff --git a/src/nodes.coffee b/src/nodes.coffee index b7bd0129..adc4d27d 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -961,8 +961,8 @@ exports.Splat = class Splat extends Base # A compiling a splat as a destructuring assignment means slicing arguments # from the right-hand-side's corresponding array. compileValue: (o, name, index, trailings) -> - trail = if trailings then ", #{name}.length - #{trailings}" else '' - "#{ utility 'slice' }.call(#{name}, #{index}#{trail})" + trail = if trailings then ', -' + trailings else '' + utility('slice') + ".call(#{name}, #{index}#{trail})" # Utility function that converts arbitrary number of elements, mixed with # splats, to a proper array