From: Feross Aboukhadijeh Date: Thu, 24 Mar 2016 02:45:03 +0000 (-0700) Subject: Fixes to PR #109 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=2028c27705dc87af4d092123dace11b147ddae0c;p=buffer.git Fixes to PR #109 --- diff --git a/index.js b/index.js index 6f85398..c939c81 100644 --- a/index.js +++ b/index.js @@ -286,7 +286,11 @@ Buffer.compare = function compare (a, b) { var y = b.length for (var i = 0, len = Math.min(x, y); i < len; ++i) { - if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1 + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } } if (x < y) return -1