mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-26 16:33:44 +00:00
optimize millis_since_unix_epoch()
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
08274150e5
commit
db46d6dd6b
|
@ -23,7 +23,7 @@ pub use mutex_map::MutexMap;
|
|||
pub use rand::string as random_string;
|
||||
pub use string::{str_from_bytes, string_from_bytes};
|
||||
pub use sys::available_parallelism;
|
||||
pub use time::millis_since_unix_epoch;
|
||||
pub use time::now_millis as millis_since_unix_epoch;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[allow(clippy::as_conversions)]
|
||||
pub fn millis_since_unix_epoch() -> u64 {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("time is valid")
|
||||
pub fn now_millis() -> u64 {
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
UNIX_EPOCH
|
||||
.elapsed()
|
||||
.expect("positive duration after epoch")
|
||||
.as_millis() as u64
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue