Skip to content

Commit

Permalink
perf: and fix, avoid calling get_test_account
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jan 7, 2025
1 parent 1d6b56c commit 3e2f68d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ape/managers/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ def __getitem__(self, account_id):

@__getitem__.register
def __getitem_int(self, account_id: int):
if account_id in self._accounts_by_index:
return self._accounts_by_index[account_id]

original_account_id = account_id
if account_id < 0:
account_id = len(self) + account_id

if account_id in self._accounts_by_index:
return self._accounts_by_index[account_id]

account = self.containers["test"].get_test_account(account_id)
self._accounts_by_index[original_account_id] = account
return account
Expand Down

0 comments on commit 3e2f68d

Please sign in to comment.