Skip to content

Commit 0f38838

Browse files
committed
perf: remove rand dependency
1 parent 20fae07 commit 0f38838

File tree

5 files changed

+8
-136
lines changed

5 files changed

+8
-136
lines changed

Cargo.lock

-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/Cargo.lock

-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[dependencies]
22
alejandra_engine = { "path" = "../src/alejandra_engine" }
33
console_error_panic_hook = "*"
4-
getrandom = { version = "*", features = ["js"] }
54
wasm-bindgen = "*"
65
wee_alloc = "*"
76

src/alejandra_engine/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[dependencies]
22
clap = { version = "*", features = ["cargo"] }
3-
rand = "*"
43
rnix = "*"
54
rowan = "0.12.6" # follows rnix
65

src/alejandra_engine/src/rules/string.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
const PLACEHOLDER: &str = "\
2+
4d13159079d76c1398db5f3ab0c62325\
3+
f884b545e63226f7ec8aad96c52e13e8\
4+
6b219abc9462c41b87e47344752e9940\
5+
abf9353565f69a5db5c672b89372b84c";
6+
17
pub fn rule(
28
build_ctx: &crate::builder::BuildCtx,
39
node: &rnix::SyntaxNode,
@@ -26,8 +32,6 @@ pub fn rule(
2632
}
2733
}
2834
} else {
29-
let placeholder = get_placeholder();
30-
3135
let elements: Vec<rnix::SyntaxElement> = children
3236
.get_remaining()
3337
.iter()
@@ -45,7 +49,7 @@ pub fn rule(
4549
let token = element.clone().into_token().unwrap();
4650
token.text().to_string()
4751
}
48-
_ => placeholder.to_string(),
52+
_ => PLACEHOLDER.to_string(),
4953
})
5054
.collect();
5155

@@ -111,7 +115,7 @@ pub fn rule(
111115

112116
for (index, line) in lines.iter().enumerate() {
113117
let portions: Vec<String> = line
114-
.split(&placeholder)
118+
.split(PLACEHOLDER)
115119
.map(|portion| portion.to_string())
116120
.collect();
117121

@@ -159,13 +163,3 @@ pub fn rule(
159163

160164
steps
161165
}
162-
163-
fn get_placeholder() -> String {
164-
use rand::RngCore;
165-
166-
let mut bytes = [0u8; 32];
167-
168-
rand::thread_rng().fill_bytes(&mut bytes);
169-
170-
bytes.iter().map(|byte| format!("{:02X}", byte)).collect()
171-
}

0 commit comments

Comments
 (0)