From a2dbe7afb66675139697de2758d46656d3f24538 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 22 Apr 2015 10:41:01 +1000 Subject: [PATCH] index: dont use empty blocks --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a7989ae..28ac51e 100644 --- a/index.js +++ b/index.js @@ -230,11 +230,20 @@ Buffer.compare = function compare (a, b) { var x = a.length var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} + + var i = 0 + var len = Math.min(x, y) + while (i < len) { + if (a[i] !== b[i]) break + + ++i + } + if (i !== len) { x = a[i] y = b[i] } + if (x < y) return -1 if (y < x) return 1 return 0 -- 2.34.1