diff --git a/Cargo.lock b/Cargo.lock index d0155c6..c4f5e68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,49 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "cc" +version = "1.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "libmimalloc-sys" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" +dependencies = [ + "cc", +] + +[[package]] +name = "mimalloc" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" +dependencies = [ + "libmimalloc-sys", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + [[package]] name = "zern" version = "0.3.0" +dependencies = [ + "mimalloc", +] diff --git a/Cargo.toml b/Cargo.toml index 1c8b388..3044485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,3 +3,9 @@ name = "zern" version = "0.3.0" edition = "2024" license = "BSD-2-Clause" + +[dependencies] +mimalloc = { version = "0.1.52", optional = true } + +[features] +mimalloc = ["dep:mimalloc"] diff --git a/src/main.rs b/src/main.rs index 3ca1b16..336cd40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,10 @@ use std::{ use tokenizer::ZernError; +#[cfg(feature = "mimalloc")] +#[global_allocator] +static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; + fn compile_file(args: Args) -> Result<(), ZernError> { let source = match fs::read_to_string(&args.path) { Ok(x) => x,