diff --git a/Cargo.toml b/Cargo.toml index e79ac24..d421ca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ license = "MIT OR Apache-2.0 OR Zlib" wgpu = { version = "0.19", default-features = false, features = ["wgsl"] } etagere = "0.2.10" cosmic-text = "0.11" -lru = "0.12.1" +lru = { version = "0.12.1", default-features = false } +rustc-hash = "1.1" [dev-dependencies] winit = { version = "0.29.10", features = ["rwh_05"] } diff --git a/src/text_atlas.rs b/src/text_atlas.rs index 44e017c..c1bc0a8 100644 --- a/src/text_atlas.rs +++ b/src/text_atlas.rs @@ -4,7 +4,11 @@ use crate::{ }; use etagere::{size2, Allocation, BucketedAtlasAllocator}; use lru::LruCache; -use std::{borrow::Cow, collections::HashSet, mem::size_of, num::NonZeroU64, sync::Arc}; +use rustc_hash::FxHasher; +use std::{ + borrow::Cow, collections::HashSet, hash::BuildHasherDefault, mem::size_of, num::NonZeroU64, + sync::Arc, +}; use wgpu::{ BindGroup, BindGroupDescriptor, BindGroupEntry, BindGroupLayout, BindGroupLayoutEntry, BindingResource, BindingType, BlendState, BufferBindingType, ColorTargetState, ColorWrites, @@ -17,6 +21,8 @@ use wgpu::{ VertexState, }; +type Hasher = BuildHasherDefault; + #[allow(dead_code)] pub(crate) struct InnerAtlas { pub kind: Kind, @@ -24,8 +30,8 @@ pub(crate) struct InnerAtlas { pub texture_view: TextureView, pub packer: BucketedAtlasAllocator, pub size: u32, - pub glyph_cache: LruCache, - pub glyphs_in_use: HashSet, + pub glyph_cache: LruCache, + pub glyphs_in_use: HashSet, pub max_texture_dimension_2d: u32, } @@ -56,8 +62,8 @@ impl InnerAtlas { let texture_view = texture.create_view(&TextureViewDescriptor::default()); - let glyph_cache = LruCache::unbounded(); - let glyphs_in_use = HashSet::new(); + let glyph_cache = LruCache::unbounded_with_hasher(Hasher::default()); + let glyphs_in_use = HashSet::with_hasher(Hasher::default()); Self { kind,