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

refactor: Refactor the equals function for readability #13650

Closed
wants to merge 1 commit into from
Closed

refactor: Refactor the equals function for readability #13650

wants to merge 1 commit into from

Conversation

TehShrike
Copy link
Contributor

  • Turn an unnecessary nested if block into an &&
  • Change the isRegExp block to use the same "if the second argument is the wrong type, return false" pattern as all the other blocks

- Turn an unnecessary nested if block into an &&
- Change the isRegExp block to use the same "if the second argument is the wrong type, return
false" pattern as all the other blocks
@gkalpak
Copy link
Member

gkalpak commented Jan 21, 2016

LGTM (does exactly as the description says - git diffing adds much more noise 😃)

@TehShrike
Copy link
Contributor Author

It's true, the no-whitespace diff is a lot shorter.

if (!isDate(o2)) return false;
return equals(o1.getTime(), o2.getTime());
} else if (isRegExp(o1)) {
if (!isRegExp(o2)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I find return isRegExp(o2) && o1.toString() == o2.toString(); easier to read, but not a blocker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Me too, but every other if (some type) block used the other pattern, and the function as a whole seemed easier to read when they all followed the same pattern.

@lgalfaso lgalfaso closed this in a277bcf Jan 22, 2016
@TehShrike TehShrike deleted the cleaning-up-equals-function branch January 22, 2016 20:09
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.

5 participants