Skip to content

Commit

Permalink
assert: simplify logic of testing buffer equality
Browse files Browse the repository at this point in the history
Delegate buffer equality check to `buffer.equals()`

PR-URL: #1171
Reviewed-By: Brendan Ashworth <[email protected]>
Reviewed-By: Christian Vaagland Tellnes <[email protected]>
  • Loading branch information
yursha authored and brendanashworth committed Mar 24, 2015
1 parent 269e46b commit 7dd5e82
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'use strict';

// UTILITY
const compare = process.binding('buffer').compare;
const util = require('util');
const pSlice = Array.prototype.slice;

Expand Down Expand Up @@ -145,13 +146,7 @@ function _deepEqual(actual, expected, strict) {
if (actual === expected) {
return true;
} else if (actual instanceof Buffer && expected instanceof Buffer) {
if (actual.length != expected.length) return false;

for (var i = 0; i < actual.length; i++) {
if (actual[i] !== expected[i]) return false;
}

return true;
return compare(actual, expected) === 0;

// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
Expand Down

0 comments on commit 7dd5e82

Please sign in to comment.