From 4b46afae09519986462bf1a0ee12419b42836528 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Dec 2020 19:20:50 +0100 Subject: WM: minor optimization for when there is a large number of notifiers Don't add the same stats refresh notifiers multiple times, it can be slow to search the full list of notifiers for duplicates when there are many. Fundamentally the time complexity in searching for duplicates is still bad. Inspired by D9901 from Erik Abrahamsson --- source/blender/windowmanager/intern/wm_event_system.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 82ca54db075..20fa500f0b3 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -423,6 +423,7 @@ void wm_event_do_notifiers(bContext *C) LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { Scene *scene = WM_window_get_active_scene(win); bool do_anim = false; + bool clear_info_stats = false; CTX_wm_window_set(C, win); @@ -489,11 +490,17 @@ void wm_event_do_notifiers(bContext *C) } } if (ELEM(note->category, NC_SCENE, NC_OBJECT, NC_GEOM, NC_WM)) { - ViewLayer *view_layer = CTX_data_view_layer(C); - ED_info_stats_clear(view_layer); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); + clear_info_stats = true; } } + + if (clear_info_stats) { + /* Only do once since adding notifiers is slow when there are many. */ + ViewLayer *view_layer = CTX_data_view_layer(C); + ED_info_stats_clear(view_layer); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); + } + if (do_anim) { /* XXX, quick frame changes can cause a crash if framechange and rendering -- cgit v1.2.3