Skip to content

Commit cba6568

Browse files
core: use LazyLock instead of OnceLock for entity regex
1 parent 3933937 commit cba6568

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/xml.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use regress::Regex;
2-
use std::sync::OnceLock;
2+
use std::{ops::Deref, sync::LazyLock};
33

4-
static ENTITY_REGEX: OnceLock<Regex> = OnceLock::new();
4+
static ENTITY_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"&[^;]*;").unwrap());
55

66
/// Handles flash-specific XML unescaping behavior.
77
/// We accept all XML entities, and also accept standalone '&' without
@@ -12,7 +12,7 @@ pub fn custom_unescape(
1212
) -> Result<String, quick_xml::Error> {
1313
let input = decoder.decode(data)?;
1414

15-
let re = ENTITY_REGEX.get_or_init(|| Regex::new(r"&[^;]*;").unwrap());
15+
let re = ENTITY_REGEX.deref();
1616
let mut result = String::new();
1717
let mut last_end = 0;
1818

0 commit comments

Comments
 (0)