explorer: small performance boost to rule generator search functionality

This commit is contained in:
Michael Hunhoff
2021-08-25 15:40:12 -06:00
parent 4af5cc66ba
commit 8ffa8ea2c8
2 changed files with 15 additions and 7 deletions

View File

@@ -59,6 +59,7 @@
- explorer: add additional filter logic when displaying matches by function #686 @mike-hunhoff
- explorer: remove duplicate check when saving file #687 @mike-hunhoff
- explorer: update IDA extractor to use non-canon mnemonics #688 @mike-hunhoff
- explorer: small performance boost to rule generator search functionality #742 @mike-hunhoff
### Development

View File

@@ -856,10 +856,13 @@ class CapaExplorerRulegenFeatures(QtWidgets.QTreeWidget):
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()
@@ -871,8 +874,10 @@ class CapaExplorerRulegenFeatures(QtWidgets.QTreeWidget):
"""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):
@@ -885,7 +890,8 @@ class CapaExplorerRulegenFeatures(QtWidgets.QTreeWidget):
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)
@@ -896,7 +902,8 @@ class CapaExplorerRulegenFeatures(QtWidgets.QTreeWidget):
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())