diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2013-08-03 15:35:09 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2013-08-03 15:35:09 +0400 |
commit | 66a40779271b55498216cc14b4df3ca8d575137c (patch) | |
tree | fdd0ed4df73ca2ecb9f3c58813e8338c53eedadb /source/blender/blenloader/intern/writefile.c | |
parent | 91d148b8914bb198a78c3789fa39c2850d37d219 (diff) |
fix for [#36260] 2,300 Objects Makes Blender Unresponsive
- performance of outliner was low because of unoptimal data structures.
- now it uses BLI_mempool instead of custom mempool and GHash to make searches for duplicates faster.
- also fix undesired behaviour of BLI_mempool_as_arrayN
thanks to Campbell Barton and Lukas Tönne for helping me get a better fix put together.
Diffstat (limited to 'source/blender/blenloader/intern/writefile.c')
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index e170107713c..12804e8042d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -144,12 +144,13 @@ #include "BLI_bitmap.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" -#include "BKE_bpath.h" #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_mempool.h" #include "BKE_action.h" #include "BKE_blender.h" +#include "BKE_bpath.h" #include "BKE_curve.h" #include "BKE_constraint.h" #include "BKE_global.h" // for G @@ -2393,6 +2394,31 @@ static void write_region(WriteData *wd, ARegion *ar, int spacetype) } } +static void write_soops(WriteData *wd, SpaceOops *so) +{ + BLI_mempool *ts = so->treestore; + + if (ts) { + int elems = BLI_mempool_count(ts); + /* linearize mempool to array */ + TreeStoreElem *data = elems ? BLI_mempool_as_arrayN(ts, "TreeStoreElem") : NULL; + TreeStore ts_flat = {elems, elems, data}; + + /* temporarily replace mempool-treestore by flat-treestore */ + so->treestore = (BLI_mempool *)&ts_flat; + writestruct(wd, DATA, "SpaceOops", 1, so); + /* restore old treestore */ + so->treestore = ts; + writestruct(wd, DATA, "TreeStore", 1, &ts_flat); + if (data) { + writestruct(wd, DATA, "TreeStoreElem", elems, data); + MEM_freeN(data); + } + } else { + writestruct(wd, DATA, "SpaceOops", 1, so); + } +} + static void write_screens(WriteData *wd, ListBase *scrbase) { bScreen *sc; @@ -2475,15 +2501,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase) } else if (sl->spacetype==SPACE_OUTLINER) { SpaceOops *so= (SpaceOops *)sl; - - writestruct(wd, DATA, "SpaceOops", 1, so); - - /* outliner */ - if (so->treestore) { - writestruct(wd, DATA, "TreeStore", 1, so->treestore); - if (so->treestore->data) - writestruct(wd, DATA, "TreeStoreElem", so->treestore->usedelem, so->treestore->data); - } + write_soops(wd, so); } else if (sl->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sl; |