aboutsummaryrefslogtreecommitdiff
path: root/codegen/lib
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2024-11-27 10:26:40 +0000
committermat <git@matdoes.dev>2024-11-27 10:26:40 +0000
commit0817382098128adcecb77756a3c7cd1bd0066057 (patch)
tree623d9b297f9b5fdb2af74ab3c5a4fa5c1b72ff5b /codegen/lib
parentdfdc3144b61b6750ad62fb493b7c00c6c820c90b (diff)
downloadazalea-drasl-0817382098128adcecb77756a3c7cd1bd0066057.tar.xz
replace once_cell with std:;sync::LazyLock
Diffstat (limited to 'codegen/lib')
-rwxr-xr-xcodegen/lib/code/shapes.py8
-rw-r--r--codegen/lib/code/tags.py5
2 files changed, 6 insertions, 7 deletions
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<VoxelShape>; 26644] = [&SHAPE0, &SHAPE1, &SHAPE1, ...]
+ # static SHAPES_MAP: [&LazyLock<VoxelShape>; 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<VoxelShape>; {len(block_state_ids_to_shape_ids)}] = ['
+ generated_map_code = f'static SHAPES_MAP: [&LazyLock<VoxelShape>; {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<VoxelShape> = Lazy::new(|| {{'
+ code += f'static SHAPE{shape_id}: LazyLock<VoxelShape> = 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<HashSet<{struct_name}>> = Lazy::new(|| HashSet::from_iter(vec!['
+ generated += f'pub static {static_set_name}: LazyLock<HashSet<{struct_name}>> = LazyLock::new(|| HashSet::from_iter(vec!['
queue = tag['values'].copy()
while queue != []: