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

small simplifications #7141

Merged
merged 3 commits into from
Nov 1, 2024
Merged

small simplifications #7141

merged 3 commits into from
Nov 1, 2024

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Oct 31, 2024

  • x === null || x === undefined --> x == null
  • [(typeof x === "string") && (x === "abc")] --> [x === "abc"]
  • [(typeof x === "number") && (x === 123)] --> [x === 123]

@cristianoc cristianoc requested review from cknitt and zth October 31, 2024 16:50
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Great!

Left some comments for more potential optimizations.

@@ -7,7 +7,7 @@ function shouldHandleNullableValues() {
let tUndefined = undefined;
let tValue = "hello";
let tmp;
tmp = tNull === null || tNull === undefined ? tNull === null : false;
tmp = (tNull == null) ? tNull === null : false;
Copy link
Member

Choose a reason for hiding this comment

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

Could be simplified to tNull === null.

@@ -18,7 +18,7 @@ function shouldHandleNullableValues() {
"Should handle null"
], tmp, (prim0, prim1) => prim0 === prim1, true);
let tmp$1;
tmp$1 = (tUndefined === null || tUndefined === undefined) && tUndefined !== null;
tmp$1 = (tUndefined == null) && tUndefined !== null;
Copy link
Member

@cknitt cknitt Oct 31, 2024

Choose a reason for hiding this comment

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

Could be simplified to tUndefined === undefined.

@@ -29,7 +29,7 @@ function shouldHandleNullableValues() {
"Should handle undefined"
], tmp$1, (prim0, prim1) => prim0 === prim1, true);
let tmp$2;
tmp$2 = tValue === null || tValue === undefined ? false : tValue === "hello";
tmp$2 = (tValue == null) ? false : tValue === "hello";
Copy link
Member

Choose a reason for hiding this comment

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

Could be simplified to tValue === "hello".

@cristianoc
Copy link
Collaborator Author

Great!

Left some comments for more potential optimizations.

Can you move them to a separate issue?
I'd like to revisit them after flashing out #7135 more.
Changing the pattern matching algorithm might generate different patterns.

@cristianoc cristianoc merged commit 43d2bbf into master Nov 1, 2024
20 checks passed
@cristianoc cristianoc deleted the small-simplifications branch November 1, 2024 12:20
@cknitt
Copy link
Member

cknitt commented Nov 1, 2024

Can you move them to a separate issue?

#7142

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.

3 participants