From 1e120e72302266e77b9c2e77c1909c118a9772a6 Mon Sep 17 00:00:00 2001 From: andreivladbrg Date: Mon, 29 Apr 2024 16:41:52 +0300 Subject: [PATCH] perf: optimize createAndDepositMultiple --- src/SablierV2OpenEnded.sol | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/SablierV2OpenEnded.sol b/src/SablierV2OpenEnded.sol index 36c48786..ca66d30f 100644 --- a/src/SablierV2OpenEnded.sol +++ b/src/SablierV2OpenEnded.sol @@ -242,7 +242,16 @@ contract SablierV2OpenEnded is ISablierV2OpenEnded, NoDelegateCall, SablierV2Ope streamIds = new uint256[](recipients.length); streamIds = createMultiple(recipients, senders, ratesPerSecond, asset); - depositMultiple(streamIds, amounts); + uint256 streamIdsCount = streamIds.length; + if (streamIdsCount != amounts.length) { + revert Errors.SablierV2OpenEnded_DepositArrayCountsNotEqual(streamIdsCount, amounts.length); + } + + // Deposit on each stream. + for (uint256 i = 0; i < streamIdsCount; ++i) { + // Checks, Effects and Interactions: deposit on stream. + _deposit(streamIds[i], amounts[i]); + } } /// @inheritdoc ISablierV2OpenEnded