[~] Performance optimizations around Attachment[] and Launchable[] arrays

AIMNAS with its ~50K elements in Attachment[] suffered of performance drop when MOLLE stuff is in the visible inventory. To resolve it the following is done:
* Introduce gMAXATTACHMENTS_READ with actual number of elements in Attachment[]; according refactoring.
* Introduce gMAXLAUNCHABLES_READ with actual number of elements in Launchable[]; according refactoring.
* Introduce std::multimap AttachmentBackmap for quick access to attachments using itemId as a key.
* Sort Attachment[] by attachmentIndex right after loading from XML. According order in XML is not needed anymore.
* Introduce FindAttachmentRange() for quick access to attachments using attachmentId as a key (binary search in Attachment[]).
In a few words, GetHelpTextForItemInLaptop(), ValidAttachment(), SetAttachmentSlotsFlag() were heavily optimized.
This commit is contained in:
sun-alf
2023-09-08 21:58:14 +03:00
parent 4c861e441a
commit f8637e5972
7 changed files with 224 additions and 170 deletions
+4 -2
View File
@@ -19,6 +19,8 @@ struct
}
typedef launchableParseData;
UINT32 gMAXLAUNCHABLES_READ = 0;
static void XMLCALL
launchableStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
{
@@ -168,9 +170,9 @@ BOOLEAN ReadInLaunchableStats(STR fileName)
return FALSE;
}
gMAXLAUNCHABLES_READ = pData.curIndex + 1;
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );