Merge branch 'master' into blender2.8
[blender.git] / source / blender / makesrna / intern / rna_access.c
index f349d4a44dc085a9a9e220b510a6ee7076e1f7aa..9a7fd9589b05dbf334fb80ad8567bf8aaa3f261d 100644 (file)
@@ -77,6 +77,9 @@ void RNA_init(void)
        StructRNA *srna;
        PropertyRNA *prop;
 
+       BLENDER_RNA.structs_map = BLI_ghash_str_new_ex(__func__, 2048);
+       BLENDER_RNA.structs_len = 0;
+
        for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
                if (!srna->cont.prophash) {
                        srna->cont.prophash = BLI_ghash_str_new("RNA_init gh");
@@ -87,6 +90,8 @@ void RNA_init(void)
                                }
                        }
                }
+               BLI_ghash_insert(BLENDER_RNA.structs_map, (void *)srna->identifier, srna);
+               BLENDER_RNA.structs_len += 1;
        }
 }
 
@@ -514,13 +519,7 @@ static const char *rna_ensure_property_name(const PropertyRNA *prop)
 
 StructRNA *RNA_struct_find(const char *identifier)
 {
-       StructRNA *type;
-       if (identifier) {
-               for (type = BLENDER_RNA.structs.first; type; type = type->cont.next)
-                       if (STREQ(type->identifier, identifier))
-                               return type;
-       }
-       return NULL;
+       return BLI_ghash_lookup(BLENDER_RNA.structs_map, identifier);
 }
 
 const char *RNA_struct_identifier(const StructRNA *type)