From 8a82c8f1c0a0ccd4766d6d8fc067edbc932ea73a Mon Sep 17 00:00:00 2001 From: eboado Date: Mon, 26 Oct 2020 11:10:57 +0100 Subject: [PATCH] - Optimized getAddressesProvidersList() on addresses provider registry. --- .../LendingPoolAddressesProviderRegistry.sol | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol index 77c260bf..f2c7dc34 100644 --- a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol +++ b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol @@ -36,13 +36,15 @@ contract LendingPoolAddressesProviderRegistry is Ownable, ILendingPoolAddressesP * @return the list of addressesProviders **/ function getAddressesProvidersList() external override view returns (address[] memory) { - uint256 maxLength = _addressesProvidersList.length; + address[] memory addressesProvidersList = _addressesProvidersList; + + uint256 maxLength = addressesProvidersList.length; address[] memory activeProviders = new address[](maxLength); - for (uint256 i = 0; i < _addressesProvidersList.length; i++) { - if (_addressesProviders[_addressesProvidersList[i]] > 0) { - activeProviders[i] = _addressesProvidersList[i]; + for (uint256 i = 0; i < maxLength; i++) { + if (_addressesProviders[addressesProvidersList[i]] > 0) { + activeProviders[i] = addressesProvidersList[i]; } }