GetConversation / GetDialogueEntry Optimization Question

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

GetConversation / GetDialogueEntry Optimization Question

Post by VoodooDetective »

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:

Code: Select all

        public Conversation GetConversation(int conversationID)
        {
            return conversations.Find(c => c.id == conversationID);
        }
Conversation:

Code: Select all

        public DialogueEntry GetDialogueEntry(int dialogueEntryID)
        {
            return dialogueEntries.Find(e => string.Equals(e.id, dialogueEntryID));
        }
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.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: GetConversation / GetDialogueEntry Optimization Question

Post by Tony Li »

It should be fine to do that. But I recommend profiling before and after. I don't know that it would give enough bang for the buck to be worth maintaining the customization.
Post Reply