From 5d278a3a77ebd832f3918cbf9a73367884697b84 Mon Sep 17 00:00:00 2001 From: Wanne Date: Sun, 2 Oct 2011 20:06:19 +0000 Subject: [PATCH] - Bugfix: Encountered save somewhere that took a long time to load a sector. The problem was something like over 1400 items in a cell in the sector. I just changed the reallocation strategy to grow by 3/2 of current size rather than fixed 10 because the number of memcopy decrease significantly at risk of allocating a larger than needed array (13 resizes vs 140 resizes). That code had other problems but this helped quite a bit (by tazpn) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4671 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/World Items.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tactical/World Items.cpp b/Tactical/World Items.cpp index 96f4f0a9..bb12cce6 100644 --- a/Tactical/World Items.cpp +++ b/Tactical/World Items.cpp @@ -378,7 +378,8 @@ INT32 GetFreeWorldItemIndex( void ) } uiOldNumWorldItems = guiNumWorldItems; - guiNumWorldItems += 10; + // grow by 3/2 as a better strategy, minimum 10 + guiNumWorldItems = max(10, guiNumWorldItems * 3 / 2); //Allocate new table with max+10 items. newWorldItems = new WORLDITEM [ guiNumWorldItems ]; if (newWorldItems == NULL)