-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buffer code never invoked - and wrong? #34
Comments
Two buffers shiuld not be equal either, but they are. Two different instances are never equal. |
Buffers are indexed collections. The reason why it appears so much faster is because function matchView(a, b) {
var count = a.length
if (count !== b.length) { // always false: `undefined === undefined`
return false
}
while (count) {
count--
if (!floatIs(a[count], b[count])) return false
// Inlined:
// var a1 = a[count]
// var b1 = b[count]
// if (!(a1 === b1 || // always true: `undefined === undefined`
// a1 !== a1 && b1 !== b1)) {
// return false // never taken: `undefined === undefined`
// }
}
return true
} Engines optimizing for those types are going to do an IC type check, and // Use `ArrayBuffer` map for own properties, remove statically known dead
code
function matchView(a, b) {
if (!isUnchangedArrayBuffer(a) || !isUnchangedArrayBuffer(b)) {
return recompile()
}
var count = a.length
b.length
while (count) {
count--
a[count]
b[count]
}
return true
}
// Remove unused properties that aren't connected to getters
function matchView(a, b) {
if (!isUnchangedArrayBuffer(a) || !isUnchangedArrayBuffer(b)) {
return recompile()
}
var count = a.length
while (count) {
count--
}
return true
}
// Remove unused arithmetic from loops and branches
// Remove unused properties that aren't connected to getters
function matchView(a, b) {
if (!isUnchangedArrayBuffer(a) || !isUnchangedArrayBuffer(b)) {
return recompile()
}
a.length
return true
}
// Remove unused properties that aren't connected to getters
function matchView(a, b) {
if (!isUnchangedArrayBuffer(a) || !isUnchangedArrayBuffer(b)) {
return recompile()
}
return true
} So in reality, the
That's why that turns out so fast. Engines use ICs to narrow types down Isiah Meadows On Tue, Sep 27, 2016 at 9:57 AM, zubuzon notifications@github.com wrote:
|
If you got a isView check first, isBuffer will never be invoked. Anyway. I'm closing this, it's a question and not an issue. |
@zubuzon I'll clarify that |
In your code in the function matchSameProto you check for isBuffer AFTER this check
Because of this, isBuffer is never invoked, but will still work! But slower performance (ran benchmark). You have to put the isBuffer check before that function.
Further, your isBuffer code seems to be wrong.
After this fixed, you will get this benchmark result:
The text was updated successfully, but these errors were encountered: