diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-23 22:44:02 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-07-23 22:44:02 +1000 |
commit | 0aee45a1174cecca6ed4bd703ef6299185fec6b8 (patch) | |
tree | e0c7d3723406fc96e6091a28df60f490efb504e1 /source/frontend/StarMerchantInterface.cpp | |
parent | 121d27446b42c960014b2e69999dad73322b05f3 (diff) |
Cache certain item generation calls from interfaces
Helps a little with the lag from recipes when having crafting interfaces open, but it's still noticeable.
Also micro-optimized Root maintenance by unlocking the Root mutexes for their respective shared_ptrs earlier once we have our own shared_ptr.
Diffstat (limited to 'source/frontend/StarMerchantInterface.cpp')
-rw-r--r-- | source/frontend/StarMerchantInterface.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/frontend/StarMerchantInterface.cpp b/source/frontend/StarMerchantInterface.cpp index 8e3ad3a..17f4995 100644 --- a/source/frontend/StarMerchantInterface.cpp +++ b/source/frontend/StarMerchantInterface.cpp @@ -127,7 +127,7 @@ PanePtr MerchantPane::createTooltip(Vec2I const& screenPosition) { auto entry = m_itemGuiList->itemAt(i); if (entry->getChildAt(screenPosition)) { auto itemConfig = m_itemList.get(i); - ItemPtr item = Root::singleton().itemDatabase()->item(ItemDescriptor(itemConfig.get("item"))); + ItemPtr item = Root::singleton().itemDatabase()->itemShared(ItemDescriptor(itemConfig.get("item"))); return ItemTooltipBuilder::buildItemTooltip(item, m_player); } } @@ -232,7 +232,7 @@ void MerchantPane::buildItemList() { void MerchantPane::setupWidget(WidgetPtr const& widget, Json const& itemConfig) { auto& root = Root::singleton(); auto assets = root.assets(); - ItemPtr item = root.itemDatabase()->item(ItemDescriptor(itemConfig.get("item"))); + ItemPtr item = root.itemDatabase()->itemShared(ItemDescriptor(itemConfig.get("item"))); String name = item->friendlyName(); if (item->count() > 1) @@ -265,7 +265,7 @@ void MerchantPane::updateSelection() { if (m_selectedIndex != NPos) { auto itemConfig = m_itemList.get(m_selectedIndex); - m_selectedItem = Root::singleton().itemDatabase()->item(ItemDescriptor(itemConfig.get("item"))); + m_selectedItem = Root::singleton().itemDatabase()->itemShared(ItemDescriptor(itemConfig.get("item"))); findChild<ButtonWidget>("spinCount.up")->enable(); findChild<ButtonWidget>("spinCount.down")->enable(); m_countTextBox->setColor(Color::White); |