mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Improve testcase _find_action
Search for the action with the closest EID to the request Previously it would return the first action that was larger than the EID
This commit is contained in:
@@ -263,22 +263,28 @@ class TestCase:
|
||||
|
||||
def _find_action(self, name: str, start_event: int, action_list):
|
||||
action: rd.ActionDescription
|
||||
bestMatch = None
|
||||
distance = 1000000
|
||||
for action in action_list:
|
||||
# If this action matches, return it
|
||||
if action.eventId >= start_event and (name == '' or name in self.action_name(action)):
|
||||
return action
|
||||
if action.eventId - start_event < distance:
|
||||
bestMatch = action
|
||||
distance = action.eventId - start_event
|
||||
|
||||
# Recurse to children - depth-first search
|
||||
ret: rd.ActionDescription = self._find_action(name, start_event, action.children)
|
||||
|
||||
# If we found our action, return
|
||||
if ret is not None:
|
||||
return ret
|
||||
if ret.eventId - start_event < distance:
|
||||
bestMatch = ret
|
||||
distance = ret.eventId - start_event
|
||||
|
||||
# Otherwise continue to next in the list
|
||||
|
||||
# If we didn't find anything, return None
|
||||
return None
|
||||
return bestMatch
|
||||
|
||||
def find_action(self, name: str, start_event: int = 0):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user