Skip to content

Commit

Permalink
owhierarchicalclustering: Fix performance on deselection
Browse files Browse the repository at this point in the history
The code had quadratic time complexity in the number of deselected items.
Fixed by a more judicious placement of calls to `_re_enumerate_selections`
  • Loading branch information
ales-erjavec committed Oct 12, 2017
1 parent 6f303b7 commit c893c85
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Orange/widgets/unsupervised/owhierarchicalclustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def select_item(self, item, state):
if item in self._selection:
if state == False:
self._remove_selection(item)
self._re_enumerate_selections()
self.selectionChanged.emit()
else:
# If item is already inside another selected item,
Expand All @@ -455,11 +456,11 @@ def select_item(self, item, state):

if state:
self._add_selection(item)
self._re_enumerate_selections()

elif item in self._selection:
self._remove_selection(item)

self._re_enumerate_selections()
self.selectionChanged.emit()

def _add_selection(self, item):
Expand Down Expand Up @@ -499,8 +500,6 @@ def _remove_selection(self, item):

del self._selection[item]

self._re_enumerate_selections()

def _selected_sub_items(self, item):
"""Return all selected subclusters under item."""
def branches(item):
Expand Down

0 comments on commit c893c85

Please sign in to comment.