55 */
66
77use std:: borrow:: Cow ;
8- use std:: collections:: { BTreeMap , HashMap } ;
8+ use std:: collections:: BTreeMap ;
99use std:: fmt:: Debug ;
10- use std:: sync:: { Arc , LazyLock , RwLock } ;
10+ use std:: sync:: Arc ;
1111
1212use godot:: builtin:: { GString , StringName } ;
1313use godot:: global:: { MethodFlags , PropertyHint , PropertyUsageFlags } ;
@@ -208,7 +208,6 @@ pub fn assemble_metadata<'a>(
208208
209209 RustScriptMetaData :: new (
210210 class. class_name ,
211- class. class_name_cstr ,
212211 class. base_type_name . as_ref ( ) . into ( ) ,
213212 props,
214213 methods,
@@ -266,7 +265,7 @@ impl From<&RustScriptMethodInfo> for MethodInfo {
266265 Self {
267266 id : value. id ,
268267 method_name : value. method_name . into ( ) ,
269- class_name : ClassId :: new_script ( value. class_name , value . class_name_cstr ) ,
268+ class_name : ClassId :: __alloc_next_unicode ( value. class_name ) ,
270269 return_type : ( & value. return_type ) . into ( ) ,
271270 arguments : value. arguments . iter ( ) . map ( |arg| arg. into ( ) ) . collect ( ) ,
272271 default_arguments : vec ! [ ] ,
@@ -317,10 +316,8 @@ pub struct RustScriptMetaData {
317316}
318317
319318impl RustScriptMetaData {
320- #[ expect( clippy:: too_many_arguments) ]
321319 pub fn new (
322320 class_name : & ' static str ,
323- class_name_cstr : & ' static std:: ffi:: CStr ,
324321 base_type_name : StringName ,
325322 properties : Box < [ RustScriptPropertyInfo ] > ,
326323 methods : Box < [ RustScriptMethodInfo ] > ,
@@ -329,7 +326,7 @@ impl RustScriptMetaData {
329326 description : & ' static str ,
330327 ) -> Self {
331328 Self {
332- class_name : ClassId :: new_script ( class_name, class_name_cstr ) ,
329+ class_name : ClassId :: __alloc_next_unicode ( class_name) ,
333330
334331 base_type_name,
335332 properties,
@@ -384,51 +381,21 @@ where
384381 }
385382}
386383
387- static DYNAMIC_INDEX_BY_CLASS_NAME : LazyLock < RwLock < HashMap < & ' static str , ClassId > > > =
388- LazyLock :: new ( RwLock :: default) ;
389-
390- trait ClassNameExtension {
391- fn new_script ( str : & ' static str , cstr : & ' static std:: ffi:: CStr ) -> Self ;
392- }
393-
394- impl ClassNameExtension for ClassId {
395- fn new_script ( str : & ' static str , cstr : & ' static std:: ffi:: CStr ) -> Self {
396- // Check if class name exists.
397- if let Some ( name) = DYNAMIC_INDEX_BY_CLASS_NAME . read ( ) . unwrap ( ) . get ( str) {
398- return * name;
399- }
400-
401- let mut map = DYNAMIC_INDEX_BY_CLASS_NAME . write ( ) . unwrap ( ) ;
402-
403- let class_name = * map. entry ( str) . or_insert_with ( || {
404- if str. is_ascii ( ) {
405- ClassId :: __alloc_next_ascii ( cstr)
406- } else {
407- ClassId :: __alloc_next_unicode ( str)
408- }
409- } ) ;
410-
411- class_name
412- }
413- }
414-
415384#[ cfg( test) ]
416385mod tests {
417386 use godot:: meta:: ClassId ;
418387
419- use crate :: static_script_registry:: ClassNameExtension ;
420-
421388 #[ test]
422389 fn new_class_name ( ) {
423- let script_name = ClassId :: new_script ( "TestScript" , c "TestScript") ;
390+ let script_name = ClassId :: __alloc_next_unicode ( "TestScript" ) ;
424391
425392 assert_eq ! ( script_name. to_cow_str( ) , "TestScript" ) ;
426393 }
427394
428395 #[ cfg( since_api = "4.4" ) ]
429396 #[ test]
430397 fn new_unicode_class_name ( ) {
431- let script_name = ClassId :: new_script ( "ÜbertragungsScript" , c "ÜbertragungsScript") ;
398+ let script_name = ClassId :: __alloc_next_unicode ( "ÜbertragungsScript" ) ;
432399
433400 assert_eq ! ( script_name. to_cow_str( ) , "ÜbertragungsScript" ) ;
434401 }
0 commit comments