/* get TreeStoreElem associated with a TreeElement
* < a: (TreeElement) tree element to find stored element for
*/
-#define TREESTORE(a) ((a) ? soops->treestore->data + (a)->store_index : NULL)
+#define TREESTORE(a) (soops->treestore->data + (a)->store_index)
/* size constants */
#define OL_Y_OFFSET 2
}
}
+/* XXX - THIS FUNCTION IS INCREDIBLY SLOW
+ * ... it can bring blenders tools and viewport to a grinding halt becuase of searching
+ * for duplicate items every times they are added.
+ *
+ * TODO (possible speedups)
+ * - use a hash for duplicate (could even store a hash per type)
+ * - use mempool for TreeElements
+ * */
static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr)
{
TreeStore *ts;
/* check if 'te' is in treestore */
tselem = ts->data;
for (a = 0; a < ts->usedelem; a++, tselem++) {
- if (tselem->id == id && tselem->used == 0) {
- if ((type == 0 && tselem->type == 0) || (tselem->type == type && tselem->nr == nr)) {
+ if ((tselem->used == 0) && (tselem->type == type) && (tselem->id == id)) {
+ if ((type == 0) || (tselem->nr == nr)) {
te->store_index = a;
tselem->used = 1;
return;