diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-08-27 06:25:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-08-27 06:29:57 +0300 |
commit | e9a6effa95796dfb9e9e760ee06ee326afc86b4a (patch) | |
tree | 10d52de4e64860168c288c7041ed558b744ea746 /source/blender/makesdna/intern/dna_genfile.c | |
parent | a32a4059da7e0230bbbd224788565ecb4c0d3ce4 (diff) |
DNA/IO: struct ghash lookup didn't set 'lastfind'
Internal inconsistency: lastfind was being checked
on every DNA_struct_find_nr call, but never set.
Gives minor speedup reading files.
Diffstat (limited to 'source/blender/makesdna/intern/dna_genfile.c')
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 499c430306b..16fbcbebe50 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -311,7 +311,21 @@ int DNA_struct_find_nr(SDNA *sdna, const char *str) } #ifdef WITH_DNA_GHASH - return (intptr_t)BLI_ghash_lookup(sdna->structs_map, str) - 1; + { + void **index_p; + int a; + + index_p = BLI_ghash_lookup_p(sdna->structs_map, str); + + if (index_p) { + a = GET_INT_FROM_POINTER(*index_p); + sdna->lastfind = a; + } + else { + a = -1; + } + return a; + } #else { int a; @@ -525,7 +539,7 @@ static void init_structDNA(SDNA *sdna, bool do_endian_swap) for (nr = 0; nr < sdna->nr_structs; nr++) { sp = sdna->structs[nr]; - BLI_ghash_insert(sdna->structs_map, sdna->types[sp[0]], SET_INT_IN_POINTER(nr + 1)); + BLI_ghash_insert(sdna->structs_map, sdna->types[sp[0]], SET_INT_IN_POINTER(nr)); } #endif } |