[Bf-blender-cvs] [e9a6eff] master: DNA/IO: struct ghash lookup didn't set 'lastfind'

Campbell Barton noreply at git.blender.org
Thu Aug 27 05:36:37 CEST 2015


Commit: e9a6effa95796dfb9e9e760ee06ee326afc86b4a
Author: Campbell Barton
Date:   Thu Aug 27 13:25:04 2015 +1000
Branches: master
https://developer.blender.org/rBe9a6effa95796dfb9e9e760ee06ee326afc86b4a

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.

===================================================================

M	source/blender/makesdna/intern/dna_genfile.c

===================================================================

diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 499c430..16fbcbe 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
 	}




More information about the Bf-blender-cvs mailing list