From bf89287c569db23cc303fcaad490acb733f78ba9 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 27 Apr 2015 23:11:58 -0700 Subject: [PATCH] Optimize lazy `slice` for `start` of `0` and an `end` value. --- lodash.src.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 79697ab0f..3464edb66 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -12342,8 +12342,13 @@ LazyWrapper.prototype.slice = function(start, end) { start = start == null ? 0 : (+start || 0); - var result = start < 0 ? this.takeRight(-start) : this.drop(start); + var result = this; + if (start < 0) { + result = this.takeRight(-start); + } else if (start) { + result = this.drop(start); + } if (end !== undefined) { end = (+end || 0); result = end < 0 ? result.dropRight(-end) : result.take(end - start);