# Slow EventRefDrawer inspector performance

**URL:** <https://qa.fmod.com/t/slow-eventrefdrawer-inspector-performance/22322>\
**Category:** Unity\
**Created:** [November 19, 2024, 1:25am UTC](https://qa.fmod.com/t/slow-eventrefdrawer-inspector-performance/22322 "2024-11-19T01:25:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron\_rh](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@aaron\_rh](https://qa.fmod.com/u/aaron_rh)\
**Post date:** [November 19, 2024, 1:25am UTC](https://qa.fmod.com/t/slow-eventrefdrawer-inspector-performance/22322/1 "2024-11-19T01:25:42Z")

</div>

We’re on FMOD 2.02.19 and our game has almost 6000 events. EventReferenceDrawers in the inspector are sluggish even when there’s only 5-10 of them, and the editor turns into a slideshow when there’s 15+.

After profiling I found EventReferenceDrawer.GetEditorEventRef() calls EventManager.EventFromString() which takes a very long time to do string comparisons, about 250k of them when EventReferenceDrawer.OnGUI() is called 50 times a frame.

I sorted EditorEvents and used List.BinarySearch() which immediately fixed editor performance. Please add a fix similar to this that doesn’t use linear search, thank you!

```auto
        private static EditorEventRef s_TempEditorEventRef = null;
        private static IComparer<EditorEventRef> s_EditorEventsComparer = Comparer<EditorEventRef>.Create((a, b) => string.Compare(a.Path, b.Path, StringComparison.CurrentCultureIgnoreCase));
        public static EditorEventRef EventFromString(string path)
        {
            AffirmEventCache();
            
            if (s_TempEditorEventRef == null)
            {
                s_TempEditorEventRef = ScriptableObject.CreateInstance<EditorEventRef>();
                eventCache.EditorEvents.Sort((a, b) => string.Compare(a.Path, b.Path, StringComparison.CurrentCultureIgnoreCase));
            }

            s_TempEditorEventRef.Path = path;
            int index = eventCache.EditorEvents.BinarySearch(s_TempEditorEventRef, s_EditorEventsComparer);
            if (index < 0)
            {
                return null;
            }

            return eventCache.EditorEvents[index];
        }

```

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [November 25, 2024, 1:44am UTC](https://qa.fmod.com/t/slow-eventrefdrawer-inspector-performance/22322/2 "2024-11-25T01:44:06Z")

</div>

Thanks for your feedback!

I have added a task to our tracker to investigate the best way to implement your suggestion.
