-
Notifications
You must be signed in to change notification settings - Fork 27.4k
refactor(Angular): make NaN check in date equality cleaner #8718
Conversation
I don't think recursion is really any better here. Refactoring this so that we can use one NaN-check without recursion would be better |
It's not really recursion if it is always invoked only one time... Whatever you like, I thought this is what you were aiming at with your comment. |
It's not going to recurse indefinitely, but it is actually recursion --- I do think we can improve it though --- you don't have to close this though, it shouldn't take too much to come up with something better. |
http://jsperf.com/ng-equals-dates-nan from a perf check the recursion option performs a bit better in v8, my guess is because of fewer calls/invocations --- but it might make sense to land that version anyway. You should re-open this |
yes, difference might be a bit smaller if the original invocation didn't invoke getTime() twice unnecessarily, but imo this is cleaner than fixing the duplicate invocations. |
I would actually still rather just have a quick and dirty "CompareNumbers()" routine that should be NaN aware, and invoke that rather than invoking equals() again --- chances are good we won't accidentally break this, but it doesn't take too big of an accident to go from recursing once and recursing indefinitely, and those are always a bit annoying |
http://jsperf.com/ng-equals-dates-nan we do slightly better with the See what one other person thinks though I guess (it's worth noting that this is definitely not a frequently evaluated section of code, so the performance doesn't matter a whole lot here, I just like writing these tests) |
I think this change is good as is |
I'm going to merge it in |
sgtm |
No description provided.