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 34bd7f4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ape/managers/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@ 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
self._accounts_by_index[account_id] = account
return account

@__getitem__.register
Expand Down

0 comments on commit 34bd7f4

Please sign in to comment.