diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-12-22 21:20:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-12-22 21:26:06 +0300 |
commit | 4b46afae09519986462bf1a0ee12419b42836528 (patch) | |
tree | 121c042d959454fcc2b70308499f5ed1cb6b6ad1 /source/blender/windowmanager/intern | |
parent | ac82904c49fe4df13e6d68f43e8e3e49526a5742 (diff) |
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
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 13 |
1 files 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 |