From 9ae69cbc9038a11be9423f436e279ce8817610d3 Mon Sep 17 00:00:00 2001 From: Greg Hurrell Date: Thu, 1 Jun 2017 08:24:08 -0700 Subject: [PATCH] Revert "Replace `unshift()` with `push()` plus `reverse()`" This reverts commit f21c36ed85f277522593f1aed902d18f787a34b1. --- src/addDigits.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/addDigits.js b/src/addDigits.js index e42f6f6..566b463 100644 --- a/src/addDigits.js +++ b/src/addDigits.js @@ -18,11 +18,11 @@ export default function addDigits( const aDigit = i < aLength ? aDigits[aLength - i - 1] : 0; const bDigit = i < bLength ? bDigits[bLength - i - 1] : 0; const sum = aDigit + bDigit + carry; - result.push(sum % base); + result.unshift(sum % base); // ~~ here is the equivalent of Math.floor; used to avoid V8 de-opt, // "Reference to a variable which requires dynamic lookup". carry = ~~(sum / base); } - return result.length ? result.reverse() : [0]; + return result.length ? result : [0]; } -- 2.37.1