Skip to content

Commit bdc3927

Browse files
committed
chore(bcrypt): migrate to mimalloc_rust
1 parent 668e4fb commit bdc3927

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

packages/bcrypt/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
authors = ["LongYinan <[email protected]>"]
3-
edition = "2018"
3+
edition = "2021"
44
name = "node-rs-bcrypt"
55
version = "0.1.0"
66

@@ -10,15 +10,13 @@ crate-type = ["cdylib"]
1010
[dependencies]
1111
blowfish = {version = "0.8", features = ["bcrypt"]}
1212
byteorder = "1"
13+
global_alloc = {path = "../../crates/alloc"}
1314
napi = "1"
1415
napi-derive = "1"
1516
phf = {version = "0.10", features = ["macros"]}
1617
radix64 = "0.6"
1718
rand = "0.8"
1819

19-
[target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies]
20-
mimalloc = {version = "0.1"}
21-
2220
[dev-dependencies]
2321
quickcheck = "1.0"
2422

packages/bcrypt/src/lib.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![deny(clippy::all)]
22
#![allow(clippy::nonstandard_macro_braces)]
33

4-
#[macro_use]
5-
extern crate napi_derive;
4+
/// Explicit extern crate to use allocator.
5+
extern crate global_alloc;
66

7-
use std::convert::TryInto;
87
use std::str::FromStr;
98

109
use napi::{CallContext, Error, JsBoolean, JsBuffer, JsNumber, JsObject, JsString, Result, Status};
10+
use napi_derive::*;
1111

1212
use crate::hash_task::HashTask;
1313
use crate::lib_bcrypt::{format_salt, gen_salt, Version};
@@ -21,14 +21,6 @@ mod lib_bcrypt;
2121
mod salt_task;
2222
mod verify_task;
2323

24-
#[cfg(all(
25-
target_arch = "x86_64",
26-
not(target_env = "musl"),
27-
not(debug_assertions)
28-
))]
29-
#[global_allocator]
30-
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
31-
3224
#[module_exports]
3325
fn init(mut exports: JsObject) -> Result<()> {
3426
exports.create_named_method("genSaltSync", js_salt)?;

0 commit comments

Comments
 (0)