GetConversation / GetDialogueEntry Optimization Question
Posted: Tue Nov 02, 2021 8:45 pm
I was just profiling our game and commenting out some (sometimes expensive) code we don't use (ex: DialogueSystemSceneEvents).
I've come across these two functions a few times:
DialogueDatabase:
Conversation:
I was wondering if there's any reason not to have these become dictionary lookups? Like, if I cache them [ID -> Entry] and [ID -> Conversation] in two different maps, would that be problematic? Seems like it could give considerable speed up (and avoid some garbage collection) in a number of places, but I assumed there might be reason it is like it is.
I've come across these two functions a few times:
DialogueDatabase:
Code: Select all
public Conversation GetConversation(int conversationID)
{
return conversations.Find(c => c.id == conversationID);
}
Code: Select all
public DialogueEntry GetDialogueEntry(int dialogueEntryID)
{
return dialogueEntries.Find(e => string.Equals(e.id, dialogueEntryID));
}