forked from bartvdbraak/blender
simple optimization for library loading, just reduce pointer indirection and use unsigned int's, gives up to 2x overall speedup for loading some libraries.
This commit is contained in:
parent
9117828902
commit
026e29a042
@ -360,36 +360,39 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* for libdata, nr has ID code, no increment */
|
/* 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 */
|
/* lasthit works fine for non-libdata, linking there is done in same sequence as writing */
|
||||||
if (onm->sorted) {
|
if (onm->sorted) {
|
||||||
OldNew entry_s, *entry;
|
OldNew entry_s, *entry;
|
||||||
|
|
||||||
entry_s.old = addr;
|
entry_s.old = addr;
|
||||||
|
|
||||||
entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
|
entry = bsearch(&entry_s, onm->entries, onm->nentries, sizeof(OldNew), verg_oldnewmap);
|
||||||
if (entry) {
|
if (entry) {
|
||||||
ID *id = entry->newp;
|
ID *id = entry->newp;
|
||||||
|
|
||||||
if (id && (!lib || id->lib)) {
|
if (id && (!lib || id->lib)) {
|
||||||
return entry->newp;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
for (i = 0; i < onm->nentries; i++) {
|
/* note, this can be a bottle neck when loading some files */
|
||||||
OldNew *entry = &onm->entries[i];
|
unsigned int nentries = (unsigned int)onm->nentries;
|
||||||
|
unsigned int i;
|
||||||
if (entry->old == addr) {
|
OldNew *entry;
|
||||||
ID *id = entry->newp;
|
|
||||||
|
for (i = 0, entry = onm->entries; i < nentries; i++, entry++) {
|
||||||
if (id && (!lib || id->lib)) {
|
if (entry->old == addr) {
|
||||||
return entry->newp;
|
ID *id = id = entry->newp;
|
||||||
|
if (id && (!lib || id->lib)) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user