Skip to content

Commit

Permalink
Cleanup, format and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Soremwar committed Dec 5, 2020
1 parent 39f2ee9 commit 32464f1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
16 changes: 8 additions & 8 deletions cli/ops/timers.rs
Expand Up @@ -8,30 +8,30 @@
//! only need to be able to start, cancel and await a single timer (or Delay, as Tokio
//! calls it) for an entire Isolate. This is what is implemented here.

use super::dispatch_minimal::minimal_op;
use super::dispatch_minimal::MinimalOp;
use crate::metrics::metrics_op;
use crate::permissions::Permissions;
use deno_core::BufVec;
use deno_core::error::AnyError;
use deno_core::error::type_error;
use deno_core::error::AnyError;
use deno_core::futures;
use deno_core::futures::channel::oneshot;
use deno_core::futures::FutureExt;
use deno_core::futures::TryFutureExt;
use deno_core::OpState;
use deno_core::serde_json;
use deno_core::serde_json::json;
use deno_core::serde_json::Value;
use deno_core::BufVec;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use serde::Deserialize;
use std::{cell::RefCell};
use std::cell::RefCell;
use std::future::Future;
use std::pin::Pin;
use std::rc::Rc;
use std::thread::sleep;
use std::time::Duration;
use std::time::Instant;
use super::dispatch_minimal::minimal_op;
use super::dispatch_minimal::MinimalOp;

pub type StartTime = Instant;

Expand Down Expand Up @@ -158,7 +158,7 @@ fn op_now(
let start_time = op_state.borrow::<StartTime>();
let seconds = start_time.elapsed().as_secs();
let mut subsec_nanos = start_time.elapsed().subsec_nanos() as f64;
let reduced_time_precision = 2_000_000 as f64; // 2ms in nanoseconds
let reduced_time_precision = 2_000_000.0; // 2ms in nanoseconds

// If the permission is not enabled
// Round the nano result on 2 milliseconds
Expand All @@ -167,7 +167,7 @@ fn op_now(
subsec_nanos -= subsec_nanos % reduced_time_precision;
}

let result = (seconds * 1_000) as f64 + (subsec_nanos / 1_000_000 as f64);
let result = (seconds * 1_000) as f64 + (subsec_nanos / 1_000_000.0);

(&mut zero_copy[0]).copy_from_slice(&result.to_be_bytes());

Expand Down
5 changes: 2 additions & 3 deletions cli/rt/11_timers.js
Expand Up @@ -18,11 +18,10 @@
}

const nowBytes = new Uint8Array(8);
function opNow(x) {
sendSync("op_now", x, nowBytes);
function opNow() {
sendSync("op_now", 0, nowBytes);
return new DataView(
Uint8Array.from(nowBytes).buffer,
0
)
.getFloat64();
}
Expand Down
2 changes: 1 addition & 1 deletion cli/rt/40_performance.js
Expand Up @@ -43,7 +43,7 @@
}

function now() {
return opNow(0);
return opNow();
}

class PerformanceEntry {
Expand Down

0 comments on commit 32464f1

Please sign in to comment.