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.
This commit is contained in:
Campbell Barton 2015-08-27 13:25:04 +10:00
parent a32a4059da
commit e9a6effa95
1 changed files with 16 additions and 2 deletions

View File

@ -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
}