From 99dce4604aa1476c58c897909429c6f3146a4bfc Mon Sep 17 00:00:00 2001 From: Gabriel-Trintinalia Date: Tue, 21 Jan 2025 20:27:00 +1100 Subject: [PATCH] Use orElseGet for efficiency, address comment of previous PR 8139 Signed-off-by: Gabriel-Trintinalia --- .../besu/ethereum/transaction/TransactionSimulator.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java index 7615f7e3708..0baa3a0b1c3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java @@ -402,8 +402,11 @@ public Optional processWithWorldUpdater( final long nonce = callParams .getNonce() - .orElse( - Optional.ofNullable(updater.get(senderAddress)).map(Account::getNonce).orElse(0L)); + .orElseGet( + () -> + Optional.ofNullable(updater.get(senderAddress)) + .map(Account::getNonce) + .orElse(0L)); final long simulationGasCap = calculateSimulationGasCap(callParams.getGasLimit(), blockHeaderToProcess.getGasLimit());