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

style(boa): minor cleanup #838

Merged
merged 4 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions boa/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,14 @@ impl Array {
let initial_value = args.get(1).cloned().unwrap_or_else(Value::undefined);
let mut length = this.get_field("length").to_length(interpreter)?;
if length == 0 {
if initial_value.is_undefined() {
return interpreter.throw_type_error(
return if initial_value.is_undefined() {
interpreter.throw_type_error(
"reduceRight was called on an empty array and with no initial value",
);
)
} else {
// early return to prevent usize subtraction errors
return Ok(initial_value);
}
Ok(initial_value)
};
}
let mut k = length - 1;
let mut accumulator = if initial_value.is_undefined() {
Expand Down
10 changes: 5 additions & 5 deletions boa/src/builtins/number/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl Number {
fraction -= digit as f64;
// Round to even.
if fraction + delta > 1.0
&& (fraction > 0.5 || (fraction - 0.5) < f64::EPSILON && digit & 1 != 0)
&& (fraction > 0.5 || (fraction - 0.5).abs() < f64::EPSILON && digit & 1 != 0)
Lan2u marked this conversation as resolved.
Show resolved Hide resolved
{
loop {
// We need to back trace already written digits in case of carry-over.
Expand Down Expand Up @@ -523,12 +523,12 @@ impl Number {

if radix == 0 {
if s.starts_with("0x") || s.starts_with("0X") {
if let Ok(i) = i32::from_str_radix(&s[2..], 16) {
return Ok(Value::integer(i));
return if let Ok(i) = i32::from_str_radix(&s[2..], 16) {
Ok(Value::integer(i))
} else {
// String can't be parsed.
return Ok(Value::from(f64::NAN));
}
Ok(Value::from(f64::NAN))
};
} else {
radix = 10
};
Expand Down