remove uuid

This commit is contained in:
Simon Gardling
2022-05-24 13:09:00 -04:00
parent e346b0a2e3
commit a60f1cb83d
4 changed files with 15 additions and 19 deletions

View File

@@ -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

View File

@@ -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)
}