Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] directly use Uint8Array
  • Loading branch information
BridgeAR committed Aug 21, 2017
commit a6018b30668b56007a5e7c448c2803c1228b775a
5 changes: 2 additions & 3 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function areSimilarRegExps(a, b) {
// barrier including the Buffer.from operation takes the advantage of the faster
// compare otherwise. 300 was the number after which compare became faster.
function areSimilarTypedArrays(a, b) {
const { from } = require('buffer').Buffer;
const len = a.byteLength;
if (len !== b.byteLength) {
return false;
Expand All @@ -130,8 +129,8 @@ function areSimilarTypedArrays(a, b) {
}
return true;
}
return compare(from(a.buffer, a.byteOffset, len),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just make this Buffer.from() to make it clearer what is happening

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am no sure I can follow. The Buffer.from part was removed intentionally. Should I add a comment to describe the Uint8Array part?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO a comment explaining just that would be great.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited the comment above the function. I am not really sure what to write besides what I now changed.

from(b.buffer, b.byteOffset, b.byteLength)) === 0;
return compare(new Uint8Array(a.buffer, a.byteOffset, len),
new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0;
}

function isFloatTypedArrayTag(tag) {
Expand Down