Skip to content

Commit

Permalink
Apply review
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Nov 22, 2022
1 parent fc791e1 commit 658d685
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions boa_engine/src/builtins/date/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ macro_rules! some_or_nan {

/// Gets a mutable reference to the inner `Date` object of `val` and stores it on `var`, or returns
/// a `TypeError` if `val` is not a `Date` object.
///
/// [spec]: https://tc39.es/ecma262/#sec-thistimevalue
macro_rules! get_mut_date {
(let $var:ident = $val:expr) => {
let mut $var = $val
Expand Down Expand Up @@ -64,14 +62,17 @@ pub(super) fn this_time_value(value: &JsValue) -> JsResult<Option<NaiveDateTime>
pub struct Date(Option<NaiveDateTime>);

impl Date {
#[inline]
/// Creates a new `Date`.
pub(crate) fn new(dt: Option<NaiveDateTime>) -> Self {
Self(dt)
}

/// Converts the `Date` into a `JsValue`, mapping `None` to `NaN` and `Some(datetime)` to
/// `JsValue::from(datetime.timestamp_millis())`.
fn as_value(&self) -> JsValue {
match self.0 {
Some(dt) => JsValue::from(dt.timestamp_millis()),
None => JsValue::from(f64::NAN),
}
self.0
.map_or_else(|| f64::NAN.into(), |dt| dt.timestamp_millis().into())
}
}

Expand Down
1 change: 1 addition & 0 deletions boa_engine/src/builtins/set/ordered_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ where
}

/// Removes all elements in the set, while preserving its capacity.
#[inline]
pub fn clear(&mut self) {
self.inner.clear();
}
Expand Down
8 changes: 4 additions & 4 deletions boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ impl Context {

while self.vm.frame().pc < self.vm.frame().code.code.len() {
#[cfg(feature = "fuzz")]
#[allow(clippy::redundant_else)]
if self.instructions_remaining == 0 {
return Err(JsError::from_native(JsNativeError::no_instructions_remain()));
} else {
{
if self.instructions_remaining == 0 {
return Err(JsError::from_native(JsNativeError::no_instructions_remain()));
}
self.instructions_remaining -= 1;
}

Expand Down

0 comments on commit 658d685

Please sign in to comment.