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