Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-11-10 06:38:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-11-10 06:38:16 +0400
commit026e29a042d1eb890e732ea94ba6dd4f5af68917 (patch)
tree4c97857257aa8c807eca18f4759ab294d1d34117
parent9117828902d6992ad18f41fd0aaa0f3406d698dd (diff)
simple optimization for library loading, just reduce pointer indirection and use unsigned int's, gives up to 2x overall speedup for loading some libraries.
-rw-r--r--source/blender/blenloader/intern/readfile.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 126c86d3b16..30331713463 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -360,36 +360,39 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
}
/* for libdata, nr has ID code, no increment */
-static void *oldnewmap_liblookup(OldNewMap *onm, void *addr, void *lib)
+static void *oldnewmap_liblookup(OldNewMap *onm, void *addr, void *lib)
{
- int i;
-
- if (addr == NULL) return NULL;
-
+ if (addr == NULL) {
+ return NULL;
+ }
+
/* lasthit works fine for non-libdata, linking there is done in same sequence as writing */
if (onm->sorted) {
OldNew entry_s, *entry;
-
+
entry_s.old = addr;
-
+
entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
if (entry) {
ID *id = entry->newp;
-
+
if (id && (!lib || id->lib)) {
- return entry->newp;
+ return id;
}
}
}
-
- for (i = 0; i < onm->nentries; i++) {
- OldNew *entry = &onm->entries[i];
-
- if (entry->old == addr) {
- ID *id = entry->newp;
-
- if (id && (!lib || id->lib)) {
- return entry->newp;
+ else {
+ /* note, this can be a bottle neck when loading some files */
+ unsigned int nentries = (unsigned int)onm->nentries;
+ unsigned int i;
+ OldNew *entry;
+
+ for (i = 0, entry = onm->entries; i < nentries; i++, entry++) {
+ if (entry->old == addr) {
+ ID *id = id = entry->newp;
+ if (id && (!lib || id->lib)) {
+ return id;
+ }
}
}
}