|
8 | 8 |
|
9 | 9 | mvItemRegistry::mvItemRegistry() |
10 | 10 | { |
11 | | - // prefill cached containers |
12 | | - for (i32 i = 0; i < CachedContainerCount; i++) |
13 | | - { |
14 | | - cachedContainersID[i] = 0; |
15 | | - cachedContainersPTR[i] = nullptr; |
16 | | - cachedItemsID[i] = 0; |
17 | | - cachedItemsPTR[i] = nullptr; |
18 | | - } |
| 11 | + // We seldom need to do a GetItem(0), and an explicit check for uuid == 0 in GetItem |
| 12 | + // slows it down. Instead of this, we add a fake entry to the allItems map, |
| 13 | + // mapping 0 to nullptr. This entry will never go away because map items are only |
| 14 | + // removed in the mvAppItem destructor. |
| 15 | + allItems[0] = nullptr; |
19 | 16 | } |
20 | 17 |
|
21 | 18 | static b8 |
@@ -47,25 +44,6 @@ TopParent(mvItemRegistry& registry) |
47 | 44 | return nullptr; |
48 | 45 | } |
49 | 46 |
|
50 | | -static void |
51 | | -CacheItem(mvItemRegistry& registry, mvAppItem* item) |
52 | | -{ |
53 | | - if (DearPyGui::GetEntityDesciptionFlags(item->type) & MV_ITEM_DESC_CONTAINER) |
54 | | - { |
55 | | - registry.cachedContainersID[registry.cachedContainerIndex] = item->uuid; |
56 | | - registry.cachedContainersPTR[registry.cachedContainerIndex] = item; |
57 | | - registry.cachedContainerIndex++; |
58 | | - if (registry.cachedContainerIndex == registry.CachedContainerCount) |
59 | | - registry.cachedContainerIndex = 0; |
60 | | - } |
61 | | - |
62 | | - registry.cachedItemsID[registry.cachedItemsIndex] = item->uuid; |
63 | | - registry.cachedItemsPTR[registry.cachedItemsIndex] = item; |
64 | | - registry.cachedItemsIndex++; |
65 | | - if (registry.cachedItemsIndex == registry.CachedContainerCount) |
66 | | - registry.cachedItemsIndex = 0; |
67 | | -} |
68 | | - |
69 | 47 | static void |
70 | 48 | UpdateChildLocations(std::vector<std::shared_ptr<mvAppItem>>* children, i32 slots) |
71 | 49 | { |
@@ -310,10 +288,6 @@ RemoveItemFromTree(mvItemRegistry& registry, mvAppItem* item) |
310 | 288 | b8 |
311 | 289 | DeleteItem(mvItemRegistry& registry, mvUUID uuid, b8 childrenOnly, i32 slot) |
312 | 290 | { |
313 | | - |
314 | | - // TODO: we probably don't need this anymore (well, only if we remove the cache) |
315 | | - CleanUpItem(registry, uuid); |
316 | | - |
317 | 291 | mvAppItem* item = GetItem(registry, uuid); |
318 | 292 | if (!item) |
319 | 293 | { |
@@ -745,25 +719,6 @@ ClearItemRegistry(mvItemRegistry& registry) |
745 | 719 | registry.viewportDrawlistRoots.clear(); |
746 | 720 | } |
747 | 721 |
|
748 | | -void |
749 | | -CleanUpItem(mvItemRegistry& registry, mvUUID uuid) |
750 | | -{ |
751 | | - for (i32 i = 0; i < registry.CachedContainerCount; i++) |
752 | | - { |
753 | | - if (registry.cachedContainersID[i] == uuid) |
754 | | - { |
755 | | - registry.cachedContainersID[i] = 0; |
756 | | - registry.cachedContainersPTR[i] = nullptr; |
757 | | - } |
758 | | - |
759 | | - if (registry.cachedItemsID[i] == uuid) |
760 | | - { |
761 | | - registry.cachedItemsID[i] = 0; |
762 | | - registry.cachedItemsPTR[i] = nullptr; |
763 | | - } |
764 | | - } |
765 | | -} |
766 | | - |
767 | 722 | b8 |
768 | 723 | AddItemWithRuntimeChecks(mvItemRegistry& registry, std::shared_ptr<mvAppItem> item, mvUUID parent, mvUUID before) |
769 | 724 | { |
@@ -803,8 +758,6 @@ AddItemWithRuntimeChecks(mvItemRegistry& registry, std::shared_ptr<mvAppItem> it |
803 | 758 |
|
804 | 759 | registry.lastItemAdded = item->uuid; |
805 | 760 |
|
806 | | - CacheItem(registry, item.get()); |
807 | | - |
808 | 761 | //--------------------------------------------------------------------------- |
809 | 762 | // STEP 1: check if an item with this name exists (NO LONGER NEEDED) |
810 | 763 | //--------------------------------------------------------------------------- |
|
0 commit comments