From 0817382098128adcecb77756a3c7cd1bd0066057 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 27 Nov 2024 10:26:40 +0000 Subject: replace once_cell with std:;sync::LazyLock --- codegen/lib/code/shapes.py | 8 ++++---- codegen/lib/code/tags.py | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'codegen') diff --git a/codegen/lib/code/shapes.py b/codegen/lib/code/shapes.py index b50cdcf1..12b333d1 100755 --- a/codegen/lib/code/shapes.py +++ b/codegen/lib/code/shapes.py @@ -71,7 +71,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report, generated_shape_code += generate_code_for_shape(shape_id, shape) - # static SHAPES_MAP: [&Lazy; 26644] = [&SHAPE0, &SHAPE1, &SHAPE1, ...] + # static SHAPES_MAP: [&LazyLock; 26644] = [&SHAPE0, &SHAPE1, &SHAPE1, ...] empty_shapes = [] full_shapes = [] @@ -92,7 +92,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report, block_state_ids_to_shape_ids.append((block_state_id, shape_id)) - generated_map_code = f'static SHAPES_MAP: [&Lazy; {len(block_state_ids_to_shape_ids)}] = [' + generated_map_code = f'static SHAPES_MAP: [&LazyLock; {len(block_state_ids_to_shape_ids)}] = [' block_state_ids_to_shape_ids = sorted(block_state_ids_to_shape_ids, key=lambda x: x[0]) @@ -118,7 +118,7 @@ def generate_block_shapes_code(blocks: dict, shapes: dict, block_states_report, use super::VoxelShape; use crate::collision::{{self, Shapes}}; use azalea_block::*; -use once_cell::sync::Lazy; +use std::sync::LazyLock; pub trait BlockWithShape {{ fn shape(&self) -> &'static VoxelShape; @@ -156,7 +156,7 @@ def generate_code_for_shape(shape_id: str, parts: list[list[float]]): def make_arguments(part: list[float]): return ', '.join(map(lambda n: str(n).rstrip('0'), part)) code = '' - code += f'static SHAPE{shape_id}: Lazy = Lazy::new(|| {{' + code += f'static SHAPE{shape_id}: LazyLock = LazyLock::new(|| {{' steps = [] if parts == (): steps.append('collision::EMPTY_SHAPE.clone()') diff --git a/codegen/lib/code/tags.py b/codegen/lib/code/tags.py index ae409001..d43b0071 100644 --- a/codegen/lib/code/tags.py +++ b/codegen/lib/code/tags.py @@ -9,8 +9,7 @@ def generate_tags(registries: dict, file_name: str, struct_name: str): generated = f'''// This file was generated by codegen/lib/code/tags.py, don't edit it manually! use std::collections::HashSet; - -use once_cell::sync::Lazy; +use std::sync::LazyLock; use crate::{struct_name}; @@ -19,7 +18,7 @@ use crate::{struct_name}; for tag_name, tag in sorted(registries.items(), key=lambda x: x[0]): tag_name = tag_name.replace('/', '_') static_set_name = to_snake_case(tag_name).upper() - generated += f'pub static {static_set_name}: Lazy> = Lazy::new(|| HashSet::from_iter(vec![' + generated += f'pub static {static_set_name}: LazyLock> = LazyLock::new(|| HashSet::from_iter(vec![' queue = tag['values'].copy() while queue != []: -- cgit v1.2.3