refactor: move "rayon" feature under "std"
This commit is contained in:
parent
1f52b5211c
commit
39c4e3e02b
3 changed files with 10 additions and 13 deletions
|
|
@ -36,7 +36,7 @@ default-features = false
|
||||||
features = ["hardcoded-data"]
|
features = ["hardcoded-data"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "swash", "fontconfig", "rayon"]
|
default = ["std", "swash", "fontconfig"]
|
||||||
fontconfig = ["fontdb/fontconfig", "std"]
|
fontconfig = ["fontdb/fontconfig", "std"]
|
||||||
no_std = ["rustybuzz/libm", "hashbrown"]
|
no_std = ["rustybuzz/libm", "hashbrown"]
|
||||||
shape-run-cache = []
|
shape-run-cache = []
|
||||||
|
|
@ -47,11 +47,11 @@ std = [
|
||||||
"sys-locale",
|
"sys-locale",
|
||||||
"ttf-parser/std",
|
"ttf-parser/std",
|
||||||
"unicode-bidi/std",
|
"unicode-bidi/std",
|
||||||
|
"rayon"
|
||||||
]
|
]
|
||||||
vi = ["modit", "syntect", "cosmic_undo_2"]
|
vi = ["modit", "syntect", "cosmic_undo_2"]
|
||||||
wasm-web = ["sys-locale?/js"]
|
wasm-web = ["sys-locale?/js"]
|
||||||
warn_on_missing_glyphs = []
|
warn_on_missing_glyphs = []
|
||||||
rayon = ["dep:rayon"]
|
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "layout"
|
name = "layout"
|
||||||
|
|
|
||||||
|
|
@ -160,9 +160,9 @@ impl Font {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test{
|
mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fonts_load_time(){
|
fn test_fonts_load_time() {
|
||||||
use crate::FontSystem;
|
use crate::FontSystem;
|
||||||
use sys_locale::get_locale;
|
use sys_locale::get_locale;
|
||||||
|
|
||||||
|
|
@ -175,9 +175,6 @@ mod test{
|
||||||
FontSystem::new_with_locale_and_db(locale, db);
|
FontSystem::new_with_locale_and_db(locale, db);
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
println!(
|
println!("Fonts load time {}ms.", now.elapsed().as_millis())
|
||||||
"Fonts load time {}ms.",
|
|
||||||
now.elapsed().as_millis()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,15 +211,15 @@ impl FontSystem {
|
||||||
pub fn into_locale_and_db(self) -> (String, fontdb::Database) {
|
pub fn into_locale_and_db(self) -> (String, fontdb::Database) {
|
||||||
(self.locale, self.db)
|
(self.locale, self.db)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Concurrently cache fonts by id list
|
/// Concurrently cache fonts by id list
|
||||||
pub fn cache_fonts(&mut self, mut ids: Vec<fontdb::ID>) {
|
pub fn cache_fonts(&mut self, mut ids: Vec<fontdb::ID>) {
|
||||||
#[cfg(feature = "rayon")]
|
#[cfg(feature = "std")]
|
||||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||||
ids = ids
|
ids = ids
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|id| {
|
.filter(|id| {
|
||||||
let contains = self.font_cache.contains_key(id);
|
let contains = self.font_cache.contains_key(id);
|
||||||
#[cfg(feature = "std")]
|
|
||||||
if !contains {
|
if !contains {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.db.make_shared_face_data(*id);
|
self.db.make_shared_face_data(*id);
|
||||||
|
|
@ -229,9 +229,9 @@ impl FontSystem {
|
||||||
})
|
})
|
||||||
.collect::<_>();
|
.collect::<_>();
|
||||||
|
|
||||||
#[cfg(feature = "rayon")]
|
#[cfg(feature = "std")]
|
||||||
let fonts = ids.par_iter();
|
let fonts = ids.par_iter();
|
||||||
#[cfg(not(feature = "rayon"))]
|
#[cfg(not(feature = "std"))]
|
||||||
let fonts = ids.iter();
|
let fonts = ids.iter();
|
||||||
|
|
||||||
fonts
|
fonts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue