Skip to content

Commit

Permalink
Update dependences.
Browse files Browse the repository at this point in the history
Switch dependency on "rand"/"random" to "fastrandom". We don't need the complexity for unique ids and the newer version of rand is even more complex.
  • Loading branch information
NSoiffer committed Mar 7, 2025
1 parent f002039 commit 267de9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
15 changes: 6 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ sxd-document = "0.3"
sxd-xpath = "0.4"
yaml-rust = "0.4"
lazy_static = "1.4"
strum = "0.26"
strum_macros = "0.26"
strum = "0.27.1"
strum_macros = "0.27.1"
error-chain = "0.12.4"
regex = "1.10"
dirs = "6.0"
bitflags = "2.5"
phf = { version = "0.11", features = ["macros"] }
rand = "0.8"
roman-numerals-rs = "3.1.0"
radix_fmt = "1.0"
unicode-script = "0.5"
Expand All @@ -40,15 +39,13 @@ env_logger = "0.11"
cfg-if = "1.0"
[target.'cfg(target_family = "wasm")'.dependencies]
zip = { version = "2.1", default-features = false, features = ["deflate"] }
fastrand = { version = "2.3.0", features = ["js"] }

[target.'cfg(not(target_family = "wasm"))'.dependencies]
zip = { version = "2.1", default-features = false, features = ["bzip2"] }
fastrand = { version = "2.3.0" }

[dependencies.getrandom]
version = "0.2"
features = ["js"]

[target.'cfg(target_os = "android")'.dependencies]
android_logger = {version = "0.14.1", optional = true}
android_logger = {version = "0.15.0", optional = true}

# # dependencies because of need to build wasm version for file i/o
# yew = "0.18.0"
Expand Down
4 changes: 2 additions & 2 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,15 +543,15 @@ pub fn errors_to_string(e: &Error) -> String {
fn add_ids(mathml: Element) -> Element {
use std::time::SystemTime;
let time = if cfg!(target_family = "wasm") {
rand::random::<usize>()
fastrand::usize(..)
} else {
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis() as usize
};
let time_part = radix_fmt::radix(time, 36).to_string();
let random_part = radix_fmt::radix(rand::random::<usize>(), 36).to_string();
let random_part = radix_fmt::radix(fastrand::u32(..), 36).to_string();
let prefix = "M".to_string() + &time_part[time_part.len() - 3..] + &random_part[random_part.len() - 4..] + "-"; // begin with letter
add_ids_to_all(mathml, &prefix, 0);
return mathml;
Expand Down

0 comments on commit 267de9c

Please sign in to comment.