Skip to content

Commit e01d558

Browse files
committed
chore(jieba): migrate to mimalloc_rust
1 parent 66014fa commit e01d558

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

packages/jieba/Cargo.toml

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

77
[lib]
88
crate-type = ["cdylib"]
99

1010
[dependencies]
11+
global_alloc = {path = "../../crates/alloc"}
1112
jieba-rs = {version = "0.6", features = ["default-dict", "tfidf", "textrank"]}
1213
napi = "1"
1314
napi-derive = "1"
1415
once_cell = "1.8"
1516

16-
[target.'cfg(all(target_arch = "x86_64", not(target_env = "musl")))'.dependencies]
17-
mimalloc = {version = "0.1"}
18-
1917
[build-dependencies]
20-
napi-build = "1.1.0"
18+
napi-build = "1"

packages/jieba/src/lib.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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

77
use std::convert::TryInto;
88
use std::str;
@@ -12,16 +12,9 @@ use napi::{
1212
CallContext, Env, Error, JsBoolean, JsBuffer, JsNumber, JsObject, JsString, JsUndefined, Result,
1313
Status,
1414
};
15+
use napi_derive::*;
1516
use once_cell::sync::OnceCell;
1617

17-
#[cfg(all(
18-
target_arch = "x86_64",
19-
not(target_env = "musl"),
20-
not(debug_assertions)
21-
))]
22-
#[global_allocator]
23-
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
24-
2518
static JIEBA: OnceCell<Jieba> = OnceCell::new();
2619
static TFIDF_INSTANCE: OnceCell<TFIDF> = OnceCell::new();
2720

0 commit comments

Comments
 (0)