Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ allow_deprecated = []
naga = { version = "26", features = ["wgsl-in", "wgsl-out", "termcolor"] }
tracing = "0.1"
regex = "1.8"
regex-syntax = "0.8"
thiserror = "2.0"
codespan-reporting = "0.12"
data-encoding = "2.3.2"
bit-set = "0.8"
rustc-hash = "1.1"
unicode-ident = "1"
once_cell = "1.17.0"
indexmap = "2"

[dev-dependencies]
Expand Down
10 changes: 4 additions & 6 deletions src/compose/comment_strip_iter.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use std::{borrow::Cow, str::Lines};

use regex::Regex;
use std::sync::LazyLock;

// outside of blocks and quotes, change state on //, /* or "
static RE_NONE: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r#"(//|/\*|\")"#).unwrap());
static RE_NONE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"(//|/\*|\")"#).unwrap());
// in blocks, change on /* and */
static RE_BLOCK: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r"(/\*|\*/)").unwrap());
static RE_BLOCK: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(/\*|\*/)").unwrap());
// in quotes, change only on "
static RE_QUOTE: once_cell::sync::Lazy<Regex> =
once_cell::sync::Lazy::new(|| Regex::new(r#"\""#).unwrap());
static RE_QUOTE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"\""#).unwrap());

#[derive(PartialEq, Eq)]
enum CommentState {
Expand Down
20 changes: 10 additions & 10 deletions src/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ use indexmap::IndexMap;
use naga::EntryPoint;
use regex::Regex;
use std::collections::{hash_map::Entry, BTreeMap, HashMap, HashSet};
use std::sync::LazyLock;
use tracing::{debug, trace};

use crate::{
Expand Down Expand Up @@ -348,17 +349,17 @@ impl Default for Composer {
check_decoration_regex: Regex::new(
format!(
"({}|{})",
regex_syntax::escape(DECORATION_PRE),
regex_syntax::escape(DECORATION_OVERRIDE_PRE)
regex::escape(DECORATION_PRE),
regex::escape(DECORATION_OVERRIDE_PRE)
)
.as_str(),
)
.unwrap(),
undecorate_regex: Regex::new(
format!(
r"(\x1B\[\d+\w)?([\w\d_]+){}([A-Z0-9]*){}",
regex_syntax::escape(DECORATION_PRE),
regex_syntax::escape(DECORATION_POST)
regex::escape(DECORATION_PRE),
regex::escape(DECORATION_POST)
)
.as_str(),
)
Expand All @@ -370,17 +371,17 @@ impl Default for Composer {
override_fn_regex: Regex::new(
format!(
r"(override\s+fn\s+)([^\s]+){}([\w\d]+){}(\s*)\(",
regex_syntax::escape(DECORATION_PRE),
regex_syntax::escape(DECORATION_POST)
regex::escape(DECORATION_PRE),
regex::escape(DECORATION_POST)
)
.as_str(),
)
.unwrap(),
undecorate_override_regex: Regex::new(
format!(
"{}([A-Z0-9]*){}",
regex_syntax::escape(DECORATION_OVERRIDE_PRE),
regex_syntax::escape(DECORATION_POST)
regex::escape(DECORATION_OVERRIDE_PRE),
regex::escape(DECORATION_POST)
)
.as_str(),
)
Expand Down Expand Up @@ -1927,8 +1928,7 @@ impl Composer {
}
}

static PREPROCESSOR: once_cell::sync::Lazy<Preprocessor> =
once_cell::sync::Lazy::new(Preprocessor::default);
static PREPROCESSOR: LazyLock<Preprocessor> = LazyLock::new(Preprocessor::default);

/// Get module name and all required imports (ignoring shader_defs) from a shader string
pub fn get_preprocessor_data(
Expand Down
Loading