Skip to content

Commit c220593

Browse files
committed
make the term name look up to be O(1) rather than O(n) list look up
1 parent 4f5e6dd commit c220593

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/isaaclab/isaaclab/managers/termination_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(self, cfg: object, env: ManagerBasedRLEnv):
5555
"""
5656
# create buffers to parse and store terms
5757
self._term_names: list[str] = list()
58+
self._term_name_to_term_idx = {name: i for i, name in enumerate(self._term_names)}
5859
self._term_cfgs: list[TerminationTermCfg] = list()
5960
self._class_term_cfgs: list[TerminationTermCfg] = list()
6061

@@ -234,7 +235,7 @@ def get_term_cfg(self, term_name: str) -> TerminationTermCfg:
234235
if term_name not in self._term_names:
235236
raise ValueError(f"Termination term '{term_name}' not found.")
236237
# return the configuration
237-
return self._term_cfgs[self._term_names.index(term_name)]
238+
return self._term_cfgs[self._term_name_to_term_idx[term_name]]
238239

239240
"""
240241
Helper functions.

0 commit comments

Comments
 (0)