Skip to content

Commit a80dd96

Browse files
committed
owhierarchicalclustering: Fix performance on deselection
The code had quadratic time complexity in the number of deselected items. Fixed by a more judicious placement of calls to `_re_enumerate_selections`
1 parent e0fb034 commit a80dd96

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Orange/widgets/unsupervised/owhierarchicalclustering.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def select_item(self, item, state):
439439
if item in self._selection:
440440
if state == False:
441441
self._remove_selection(item)
442+
self._re_enumerate_selections()
442443
self.selectionChanged.emit()
443444
else:
444445
# If item is already inside another selected item,
@@ -455,11 +456,11 @@ def select_item(self, item, state):
455456

456457
if state:
457458
self._add_selection(item)
458-
self._re_enumerate_selections()
459459

460460
elif item in self._selection:
461461
self._remove_selection(item)
462462

463+
self._re_enumerate_selections()
463464
self.selectionChanged.emit()
464465

465466
def _add_selection(self, item):
@@ -499,8 +500,6 @@ def _remove_selection(self, item):
499500

500501
del self._selection[item]
501502

502-
self._re_enumerate_selections()
503-
504503
def _selected_sub_items(self, item):
505504
"""Return all selected subclusters under item."""
506505
def branches(item):

0 commit comments

Comments
 (0)