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

[Merged by Bors] - Fix PartialEq for JsBigInt and f64 #2461

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions boa_engine/src/bigint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,21 @@ impl PartialEq<JsBigInt> for i32 {
impl PartialEq<f64> for JsBigInt {
#[inline]
fn eq(&self, other: &f64) -> bool {
if other.fract() != 0.0 {
return false;
if other.fract().is_zero() {
Copy link
Member

Choose a reason for hiding this comment

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

This could just be an && operation, right? Instead of an if/else

RawBigInt::from_f64(*other).map_or(false, |bigint| self.inner.as_ref() == &bigint)
} else {
false
}

self.inner.as_ref() == &RawBigInt::from(*other as i64)
}
}

impl PartialEq<JsBigInt> for f64 {
#[inline]
fn eq(&self, other: &JsBigInt) -> bool {
if self.fract() != 0.0 {
return false;
if self.fract().is_zero() {
Copy link
Member

Choose a reason for hiding this comment

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

Same here, it could just be an && operation.

RawBigInt::from_f64(*self).map_or(false, |bigint| other.inner.as_ref() == &bigint)
} else {
false
}

&RawBigInt::from(*self as i64) == other.inner.as_ref()
}
}