From a60f1cb83d5f44c6d9de441b9c6d92ac91f3b904 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 24 May 2022 13:09:00 -0400 Subject: [PATCH] remove uuid --- Cargo.lock | 16 +++------------- Cargo.toml | 3 ++- src/function_manager.rs | 8 +++----- src/misc.rs | 7 +++++++ 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 311c800..f006fec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -625,7 +625,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ee87af31d84ef885378aebca32be3d682b0e0dc119d5b4860a2c5bb5046730" dependencies = [ - "uuid 0.8.2", + "uuid", ] [[package]] @@ -2133,7 +2133,7 @@ dependencies = [ "debugid", "memmap2 0.5.3", "stable_deref_trait", - "uuid 0.8.2", + "uuid", ] [[package]] @@ -2402,16 +2402,6 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -[[package]] -name = "uuid" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cfcd319456c4d6ea10087ed423473267e1a071f3bc0aa89f80d60997843c6f0" -dependencies = [ - "getrandom", - "rand", -] - [[package]] name = "valuable" version = "0.1.0" @@ -2811,6 +2801,7 @@ dependencies = [ "egui", "emath", "epaint", + "getrandom", "instant", "itertools", "lazy_static", @@ -2826,7 +2817,6 @@ dependencies = [ "tracing-subscriber", "tracing-wasm", "unzip-n", - "uuid 1.0.0", "wasm-bindgen", "web-sys", "wee_alloc", diff --git a/Cargo.toml b/Cargo.toml index fa86135..ad6e52e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,6 @@ ruzstd = { git = "https://github.com/Titaniumtown/zstd-rs.git", branch = "ringbu tracing = "0.1" itertools = "0.10" static_assertions = "1.1" -uuid = { version = "1", features = ["v4", "fast-rng", "js"] } bincode = "1.3" serde = "1" unzip-n = "0.1" @@ -82,6 +81,7 @@ instant = "0.1" tracing-subscriber = "0.3" rayon = { version = "1.5", optional = true } async-lock = { version = "2.5", optional = true } +getrandom = { version = "0.2" } [target.'cfg(target_arch = "wasm32")'.dependencies] instant = { version = "0.1", features = ["wasm-bindgen"] } @@ -89,6 +89,7 @@ wee_alloc = "0.4" wasm-bindgen = { version = "0.2", default-features = false, features = ["std"] } web-sys = "0.3" tracing-wasm = "0.2" +getrandom = { version = "0.2", features = ["js"] } [package.metadata.cargo-all-features] skip_optional_dependencies = true #don't test optional dependencies, only features diff --git a/src/function_manager.rs b/src/function_manager.rs index b6ccce3..2617a52 100644 --- a/src/function_manager.rs +++ b/src/function_manager.rs @@ -1,5 +1,6 @@ use crate::consts::is_mobile; use crate::function_entry::FunctionEntry; +use crate::misc::random_u64; use crate::widgets::widgets_ontop; use egui::{Button, Id, Key, Modifiers, TextEdit, WidgetText}; use emath::vec2; @@ -10,7 +11,6 @@ use serde::Deserializer; use serde::Serialize; use serde::Serializer; use std::ops::BitXorAssign; -use uuid::Uuid; pub struct FunctionManager { functions: Vec<(Id, FunctionEntry)>, @@ -18,11 +18,9 @@ pub struct FunctionManager { impl Default for FunctionManager { fn default() -> Self { - // hash of 684fc8be-4ba0-408d-96ef-480b0642126f - // is 11414819524356497634 Self { functions: vec![( - Id::new_from_u64(11414819524356497634), // Random uuid here to avoid call to `Uuid::new_v4()` + Id::new_from_u64(11414819524356497634), // Random number here to avoid call to random FunctionEntry::EMPTY, )], } @@ -237,7 +235,7 @@ impl FunctionManager { /// Create and push new empty function entry pub fn push_empty(&mut self) { self.functions - .push((Id::new(Uuid::new_v4()), FunctionEntry::EMPTY)); + .push((Id::new_from_u64(random_u64()), FunctionEntry::EMPTY)); } /// Detect if any functions are using integrals diff --git a/src/misc.rs b/src/misc.rs index a0deefe..87a7165 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -1,6 +1,7 @@ use std::{intrinsics::assume, ops::RangeInclusive}; use egui::plot::{Line, Points, Value, Values}; +use getrandom::getrandom; use itertools::Itertools; /// [`SteppedVector`] is used in order to efficiently sort through an ordered @@ -286,3 +287,9 @@ pub const fn hashed_storage_read(data: &str) -> Option<(HashBytes, &[u8])> { &decoded_1[HASH_LENGTH..], )) } + +pub fn random_u64() -> u64 { + let mut data: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0]; + getrandom(&mut data).expect("unable to generate random number"); + u64::from_be_bytes(data) +}