[Bf-blender-cvs] [4b46afae095] master: WM: minor optimization for when there is a large number of notifiers

Brecht Van Lommel noreply at git.blender.org
Tue Dec 22 19:28:36 CET 2020


Commit: 4b46afae09519986462bf1a0ee12419b42836528
Author: Brecht Van Lommel
Date:   Tue Dec 22 19:20:50 2020 +0100
Branches: master
https://developer.blender.org/rB4b46afae09519986462bf1a0ee12419b42836528

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

===================================================================

M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

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



More information about the Bf-blender-cvs mailing list