Skip to content

Commit

Permalink
explorer: small performance boost to rule generator search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-hunhoff committed Aug 25, 2021
1 parent 4af5cc6 commit 2211e82
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions capa/ida/plugin/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,13 @@ def filter_items_by_text(self, text):
if data:
to_match = data.get_value_str()
if not to_match or text.lower() not in to_match.lower():
o.setHidden(True)
if not o.isHidden():
o.setHidden(True)
continue
o.setHidden(False)
o.setExpanded(True)
if o.isHidden():
o.setHidden(False)
if o.childCount() and not o.isExpanded():
o.setExpanded(True)
else:
self.show_all_items()

Expand All @@ -871,8 +874,10 @@ def show_item_and_parents(_o):
"""iteratively show and expand an item and its' parents"""
while _o:
visited.append(_o)
_o.setHidden(False)
_o.setExpanded(True)
if _o.isHidden():
_o.setHidden(False)
if _o.childCount() and not _o.isExpanded():
_o.setExpanded(True)
_o = _o.parent()

for o in iterate_tree(self):
Expand All @@ -885,7 +890,8 @@ def show_item_and_parents(_o):

if o_ea == "":
# ea may be empty, hide by default
o.setHidden(True)
if not o.isHidden():
o.setHidden(True)
continue

o_ea = int(o_ea, 16)
Expand All @@ -896,7 +902,8 @@ def show_item_and_parents(_o):
show_item_and_parents(o)
else:
# made it here, hide by default
o.setHidden(True)
if not o.isHidden():
o.setHidden(True)

# resize the view for UX
resize_columns_to_content(self.header())
Expand Down

0 comments on commit 2211e82

Please sign in to comment.