Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

refactor(Angular): make NaN check in date equality cleaner #8718

Closed
wants to merge 1 commit into from
Closed

refactor(Angular): make NaN check in date equality cleaner #8718

wants to merge 1 commit into from

Conversation

shahata
Copy link
Contributor

@shahata shahata commented Aug 22, 2014

No description provided.

@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

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

@shahata
Copy link
Contributor Author

shahata commented Aug 22, 2014

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.

@shahata shahata closed this Aug 22, 2014
@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

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.

@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

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

@shahata shahata reopened this Aug 22, 2014
@shahata
Copy link
Contributor Author

shahata commented Aug 22, 2014

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.

@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

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

@caitp caitp added this to the 1.3.0-beta.19 milestone Aug 22, 2014
@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

http://jsperf.com/ng-equals-dates-nan we do slightly better with the compareNumbers() version --- since it doesn't have to do very much work in order to compare them, honestly I would prefer something like that.

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)

@IgorMinar
Copy link
Contributor

I think this change is good as is

@IgorMinar
Copy link
Contributor

I'm going to merge it in

@caitp
Copy link
Contributor

caitp commented Aug 22, 2014

sgtm

@IgorMinar IgorMinar closed this in 642af96 Aug 22, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants