From 78a22ead6659d34ba11e10e0e419e2e0b365dca8 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 7 Aug 2023 19:46:12 +0100 Subject: [PATCH] Skip iterating over items if is null or empty --- .../Utils/Insurance/InsuredItemManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/project/Aki.SinglePlayer/Utils/Insurance/InsuredItemManager.cs b/project/Aki.SinglePlayer/Utils/Insurance/InsuredItemManager.cs index 792431a..ef10fbb 100644 --- a/project/Aki.SinglePlayer/Utils/Insurance/InsuredItemManager.cs +++ b/project/Aki.SinglePlayer/Utils/Insurance/InsuredItemManager.cs @@ -10,7 +10,7 @@ namespace Aki.SinglePlayer.Utils.Insurance public class InsuredItemManager { private static InsuredItemManager _instance; - private List items; + private List _items; public static InsuredItemManager Instance { @@ -27,13 +27,18 @@ namespace Aki.SinglePlayer.Utils.Insurance public void Init() { - items = Singleton.Instance?.MainPlayer?.Profile?.Inventory?.AllRealPlayerItems.ToList(); + _items = Singleton.Instance?.MainPlayer?.Profile?.Inventory?.AllRealPlayerItems.ToList(); } public List GetTrackedItems() { var itemsToSend = new List(); - foreach (var item in items) + if (_items == null || _items.Count() == 0) + { + return itemsToSend; + } + + foreach (var item in _items) { var aki = new AkiInsuredItemClass {