replace OnceLock with LazyLock
This commit is contained in:
parent
6ff544131b
commit
b6ecdf6385
|
@ -4,7 +4,7 @@ mod execute;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
ops::RangeInclusive,
|
ops::RangeInclusive,
|
||||||
sync::OnceLock,
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use execute::{Condition, Execute};
|
pub use execute::{Condition, Execute};
|
||||||
|
@ -432,8 +432,7 @@ impl ReturnCommand {
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
fn validate_raw_cmd(cmd: &str, pack_formats: &RangeInclusive<u8>) -> bool {
|
fn validate_raw_cmd(cmd: &str, pack_formats: &RangeInclusive<u8>) -> bool {
|
||||||
static CMD_FORMATS: OnceLock<HashMap<&str, RangeInclusive<u8>>> = OnceLock::new();
|
static CMD_FORMATS: LazyLock<HashMap<&str, RangeInclusive<u8>>> = LazyLock::new(|| {
|
||||||
let cmd_formats = CMD_FORMATS.get_or_init(|| {
|
|
||||||
const LATEST: u8 = Datapack::LATEST_FORMAT;
|
const LATEST: u8 = Datapack::LATEST_FORMAT;
|
||||||
const ANY: RangeInclusive<u8> = 0..=LATEST;
|
const ANY: RangeInclusive<u8> = 0..=LATEST;
|
||||||
const fn to(to: u8) -> RangeInclusive<u8> {
|
const fn to(to: u8) -> RangeInclusive<u8> {
|
||||||
|
@ -541,7 +540,7 @@ fn validate_raw_cmd(cmd: &str, pack_formats: &RangeInclusive<u8>) -> bool {
|
||||||
});
|
});
|
||||||
|
|
||||||
cmd.split_ascii_whitespace().next().is_none_or(|cmd| {
|
cmd.split_ascii_whitespace().next().is_none_or(|cmd| {
|
||||||
cmd_formats.get(cmd).is_none_or(|range| {
|
CMD_FORMATS.get(cmd).is_none_or(|range| {
|
||||||
let start_cmd = range.start();
|
let start_cmd = range.start();
|
||||||
let end_cmd = range.end();
|
let end_cmd = range.end();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue