Skip to content

Commit e35c70b

Browse files
authored
Merge branch 'main' into jules-18031381421240302451-d36d1f22
2 parents e2d2720 + 599fa28 commit e35c70b

26 files changed

Lines changed: 1997 additions & 1801 deletions

File tree

Cargo.lock

Lines changed: 168 additions & 279 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ anyhow = { workspace = true }
3737
rustyline = { workspace = true }
3838
toml = { workspace = true }
3939
indexmap = { workspace = true }
40-
bincode = "1.3"
40+
bincode = "3.0"
4141
dirs = "6.0"
4242
num_cpus = "1.15"
43-
ureq = { version = "2.9.0" }
43+
ureq = { version = "3.4.0" }
4444

4545
[build-dependencies]
4646
winres = "0.1.12"

cli/src/main.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,19 @@ capabilities = ["FileSystem", "Environment", "Process", "Network"]
267267
}
268268
}
269269

270-
fn levenshtein(a: &str, b: &str) -> usize {
271-
let mut cache = vec![0; b.len() + 1];
272-
for (i, val) in cache.iter_mut().enumerate() {
270+
fn levenshtein(a: &str, b: &str, cache: &mut [usize]) -> usize {
271+
let b_len = b.len();
272+
273+
// We only need bytes since commands are ascii
274+
let a_bytes = a.as_bytes();
275+
let b_bytes = b.as_bytes();
276+
277+
for (i, val) in cache[..=b_len].iter_mut().enumerate() {
273278
*val = i;
274279
}
275-
for (i, ca) in a.chars().enumerate() {
280+
for (i, &ca) in a_bytes.iter().enumerate() {
276281
let mut temp = i + 1;
277-
for (j, cb) in b.chars().enumerate() {
282+
for (j, &cb) in b_bytes.iter().enumerate() {
278283
let next = if ca == cb {
279284
cache[j]
280285
} else {
@@ -283,9 +288,9 @@ fn levenshtein(a: &str, b: &str) -> usize {
283288
cache[j] = temp;
284289
temp = next;
285290
}
286-
cache[b.len()] = temp;
291+
cache[b_len] = temp;
287292
}
288-
cache[b.len()]
293+
cache[b_len]
289294
}
290295

291296
fn suggest_subcommand(unknown: &str) {
@@ -322,9 +327,10 @@ fn suggest_subcommand(unknown: &str) {
322327
"self",
323328
];
324329

330+
let mut cache = [0; 32];
325331
let mut matches = Vec::new();
326332
for cmd in SUBCOMMANDS {
327-
let dist = levenshtein(unknown, cmd);
333+
let dist = levenshtein(unknown, cmd, &mut cache);
328334
if dist <= 3 {
329335
matches.push(*cmd);
330336
}

compiler/bytecode/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ techscript_syntax = { path = "../syntax" }
1010
techscript_ast = { path = "../ast" }
1111
techscript_ir = { path = "../ir" }
1212
serde = { workspace = true }
13-
bincode = "1.3"
13+
bincode = "3.0"
1414

1515
[dev-dependencies]
1616
techscript_errors = { path = "../errors" }
@@ -19,4 +19,4 @@ techscript_parser = { path = "../parser" }
1919
techscript_semantic = { path = "../semantic" }
2020
techscript_optimizer = { path = "../optimizer" }
2121
serde = { workspace = true }
22-
bincode = "1.3"
22+
bincode = "3.0"

0 commit comments

Comments
 (0)