From 34bd7f4f5d73135be3e2b3cb5197c439515f4e96 Mon Sep 17 00:00:00 2001 From: antazoey Date: Mon, 6 Jan 2025 19:01:32 -0600 Subject: [PATCH] perf: and fix, avoid calling get_test_account --- src/ape/managers/accounts.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ape/managers/accounts.py b/src/ape/managers/accounts.py index 860925710f..d4ebab8838 100644 --- a/src/ape/managers/accounts.py +++ b/src/ape/managers/accounts.py @@ -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