Skip to content

Commit

Permalink
Replace HashMap and strip windows binary.
Browse files Browse the repository at this point in the history
Now uses hashbrown hashmap. It's a) faster, and b) has a deterministic
print representation, which is necessary for snapshot testing.

Also strips the windows binary now
  • Loading branch information
KnorrFG committed Nov 5, 2023
1 parent 95f63fb commit e9948c4
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 13 deletions.
51 changes: 50 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dotree"
version = "0.5.0"
version = "0.5.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -19,6 +19,7 @@ clap = { version = "4.4.6", features = ["derive"] }
console = "0.15.7"
ctrlc = "3.4.1"
dirs = "5.0.1"
hashbrown = "0.14.2"
log = "0.4.20"
once_cell = "1.18.0"
pest = "2.7.4"
Expand Down
2 changes: 2 additions & 0 deletions mk-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ pkg_id="$(cargo pkgid)"
tag=${pkg_id##*#}

cargo test

cargo build --release --target=x86_64-unknown-linux-musl
strip target/x86_64-unknown-linux-musl/release/dt

cargo build --release --target=x86_64-pc-windows-gnu
strip target/x86_64-pc-windows-gnu/release/dt.exe

gh release create "$tag"\
--draft
Expand Down
4 changes: 2 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustyline::{Completer, Helper, Hinter, Validator};
use std::env;
use std::io::Write;
use std::path::PathBuf;
use std::process::{exit, Stdio};
use std::process::Stdio;
use std::{fs, io};

use crate::outproxy::OutProxy;
Expand Down Expand Up @@ -165,7 +165,7 @@ fn exec_cmd<'a>(shell_name: &'a str, mut args: Vec<&'a str>) -> Result<()> {
fn exec_cmd(shell_name: &str, args: Vec<&str>) -> Result<()> {
// windows doesn't have an exec, let's do this instead
run_subcommand(shell_name, &args, false)?;
exit(0);
std::process::exit(0);
}

fn run_subcommand(prog: &str, args: &[&str], ignore_result: bool) -> Result<()> {
Expand Down
19 changes: 10 additions & 9 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::{HashMap, VecDeque};
use hashbrown::HashMap;
use std::collections::VecDeque;

use pest::{
iterators::{Pair, Pairs},
Expand Down Expand Up @@ -430,25 +431,25 @@ mod tests {
display_name: None,
entries: {
[
'h',
'c',
]: Command(
Command {
exec_str: "echo hi",
exec_str: "echo ciao",
settings: [],
name: Some(
"print hi",
),
name: None,
shell: None,
env_vars: [],
},
),
[
'c',
'h',
]: Command(
Command {
exec_str: "echo ciao",
exec_str: "echo hi",
settings: [],
name: None,
name: Some(
"print hi",
),
shell: None,
env_vars: [],
},
Expand Down

0 comments on commit e9948c4

Please sign in to comment.