Skip to content

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Apr 23, 2019

Found a few leftovers. Seems like it's nice to fix if it's in the tight paths.

@pbondoer
Copy link

Just a curious passerby (so if you don't have time to reply I completely understand), but what's the benefit of using triple-equality here? Does the implicit boolean cast impact performance (though I would find that strange...)? Or does it not matter much / at all, and is simply to not rely on truthy / falsy and be declarative and explicit? Perhaps for code readability and/or consistency in the codebase?

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 23, 2019

There is very minor performance impact because double equals is like comparing to null, undefined, and document.all (yeah for realz). Maybe it doesn’t matter but this is also a very tight code path. The more explicit we are, the easier it is for VM to run code fast.

@gaearon gaearon merged commit 299a271 into facebook:master Apr 23, 2019
@pbondoer
Copy link

pbondoer commented Apr 24, 2019

@gaearon Double equality? It seems to me that you used triple equality here :o? You're only checking against null now?

@gaearon
Copy link
Collaborator Author

gaearon commented Apr 24, 2019

Sorry I mean the implicit boolean coercion in the condition. That thing will check for “falsy” which is too broad and includes weird cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants