From 6fec6c26fcdb7c7144f9ec4aa20ddce4824d086d Mon Sep 17 00:00:00 2001 From: Durman Date: Fri, 3 Jun 2022 12:52:31 +0400 Subject: [PATCH] optimization of objects number updating --- core/sockets.py | 19 ++++--------------- node_tree.py | 5 ----- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/core/sockets.py b/core/sockets.py index 57d0edfaca..b27d4cea31 100644 --- a/core/sockets.py +++ b/core/sockets.py @@ -438,6 +438,10 @@ def sv_set(self, data): """Set data, provide context in case the node can be evaluated several times in different context""" if self.is_output: data = self.postprocess_output(data) + + # it's expensive to call sv_get method to update the number in other places + self.objects_number = len(data) + sv_set_socket(self, data) def sv_forget(self): @@ -548,21 +552,6 @@ def draw_label(text): def draw_color(self, context, node): return self.color - def update_objects_number(self): # todo should be the method here? - """ - Should be called each time after process method of the socket owner - It will update number of objects to show in socket labels - """ - try: - self.objects_number = len(self.sv_get(deepcopy=False, default=[])) - except LookupError: - self.objects_number = 0 - except Exception as e: - warning(f"Socket='{self.name}' of node='{self.node.name}' can't update number of objects on the label. " - f"Cause is '{e}'") - self.objects_number = 0 - raise e - class SvObjectSocket(NodeSocket, SvSocketCommon): bl_idname = "SvObjectSocket" diff --git a/node_tree.py b/node_tree.py index 8ea275a5c5..b049c7ebe3 100644 --- a/node_tree.py +++ b/node_tree.py @@ -315,11 +315,6 @@ def update_ui(self, error=None, update_time=None): else: sv_bgl.callback_disable(update_pref + self.node_id) - # update object numbers - for s in chain(self.inputs, self.outputs): - if hasattr(s, 'update_objects_number'): - s.update_objects_number() - def insert_link(self, link): """It will be triggered only if one socket is connected with another by user"""