Skip to content
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

Eliminate redundant instanceof check in JS output #228

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Eliminate redundant instanceof check in JS output #228

merged 1 commit into from
Sep 5, 2023

Conversation

JakeWharton
Copy link
Collaborator

Before:

protoOf(IntAndLong).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof IntAndLong))
    return false;
  var tmp0_other_with_cast = other instanceof IntAndLong ? other : THROW_CCE();
  if (!(this.v_1 === tmp0_other_with_cast.v_1))
    return false;
  if (!this.w_1.equals(tmp0_other_with_cast.w_1))
    return false;
  return true;
};

After:

protoOf(IntAndLong).equals = function (other) {
  if (this === other)
    return true;
  if (!(other instanceof IntAndLong))
    return false;
  if (!(this.v_1 === other.v_1))
    return false;
  if (!this.w_1.equals(other.w_1))
    return false;
  return true;
};

Refs #204

Before:

  protoOf(IntAndLong).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof IntAndLong))
      return false;
    var tmp0_other_with_cast = other instanceof IntAndLong ? other : THROW_CCE();
    if (!(this.v_1 === tmp0_other_with_cast.v_1))
      return false;
    if (!this.w_1.equals(tmp0_other_with_cast.w_1))
      return false;
    return true;
  };

After:

  protoOf(IntAndLong).equals = function (other) {
    if (this === other)
      return true;
    if (!(other instanceof IntAndLong))
      return false;
    if (!(this.v_1 === other.v_1))
      return false;
    if (!this.w_1.equals(other.w_1))
      return false;
    return true;
  };
@drewhamilton drewhamilton enabled auto-merge (squash) September 5, 2023 22:28
@drewhamilton drewhamilton merged commit 77f4c9e into drewhamilton:main Sep 5, 2023
@JakeWharton JakeWharton deleted the jw.js-equals.2023-09-05 branch September 6, 2023 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants