mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-04-14 04:56:35 +00:00
[naga] Use racy::OnceBox
for Namer::default
(#7517)
This commit is contained in:
parent
27115f7d57
commit
e45013645f
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2419,6 +2419,7 @@ dependencies = [
|
||||
"itertools 0.13.0",
|
||||
"log",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"petgraph 0.8.0",
|
||||
"pp-rs",
|
||||
"ron",
|
||||
|
@ -96,6 +96,7 @@ indexmap.workspace = true
|
||||
log = "0.4"
|
||||
# `half` requires 0.2.16 for `FromBytes` and `ToBytes`.
|
||||
num-traits = { version = "0.2.16", default-features = false }
|
||||
once_cell = { workspace = true, features = ["alloc", "race"] }
|
||||
strum = { workspace = true, optional = true }
|
||||
spirv = { version = "0.3", optional = true }
|
||||
thiserror.workspace = true
|
||||
|
@ -1,11 +1,14 @@
|
||||
use alloc::{
|
||||
borrow::Cow,
|
||||
boxed::Box,
|
||||
format,
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
use core::hash::{Hash, Hasher};
|
||||
|
||||
use hashbrown::HashSet;
|
||||
use once_cell::race::OnceBox;
|
||||
|
||||
use crate::{arena::Handle, FastHashMap, FastHashSet};
|
||||
|
||||
@ -46,15 +49,13 @@ pub struct Namer {
|
||||
reserved_prefixes: Vec<&'static str>,
|
||||
}
|
||||
|
||||
#[cfg(any(wgsl_out, glsl_out, msl_out, hlsl_out, test))]
|
||||
impl Default for Namer {
|
||||
fn default() -> Self {
|
||||
use std::sync::LazyLock;
|
||||
static DEFAULT_KEYWORDS: LazyLock<HashSet<&'static str>> = LazyLock::new(HashSet::default);
|
||||
static DEFAULT_KEYWORDS: OnceBox<HashSet<&'static str>> = OnceBox::new();
|
||||
|
||||
Self {
|
||||
unique: Default::default(),
|
||||
keywords: &DEFAULT_KEYWORDS,
|
||||
keywords: DEFAULT_KEYWORDS.get_or_init(|| Box::new(HashSet::default())),
|
||||
keywords_case_insensitive: Default::default(),
|
||||
reserved_prefixes: Default::default(),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user