From af91519f7f1410721fea401b00c95c0a56f8ba13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marin=20Petruni=C4=87?= Date: Mon, 20 Nov 2023 21:00:55 +0100 Subject: [PATCH] fix: unnecessary array copy when pack encoding (#6553) * fix: unnecessary array copy when pack encoding Signed-off-by: Marin Petrunic * fix: remove unreachable code Signed-off-by: Marin Petrunic * remove unsupported test fixture Signed-off-by: Marin Petrunic --------- Signed-off-by: Marin Petrunic Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> --- packages/web3-utils/CHANGELOG.md | 4 ++++ packages/web3-utils/src/hash.ts | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/web3-utils/CHANGELOG.md b/packages/web3-utils/CHANGELOG.md index 7a09eec979a..bd385bdf0c5 100644 --- a/packages/web3-utils/CHANGELOG.md +++ b/packages/web3-utils/CHANGELOG.md @@ -176,3 +176,7 @@ Documentation: - `SocketProvider` now contains public function `getPendingRequestQueueSize`, `getSentRequestsQueueSize` and `clearQueues` (#6479) - Added `safeDisconnect` as a `SocketProvider` method to disconnect only when request queue size and send request queue size is 0 (#6479) - Add `isContractInitOptions` method (#6555) + +### Fixed + +- Fix unecessary array copy when pack encoding (#6553) diff --git a/packages/web3-utils/src/hash.ts b/packages/web3-utils/src/hash.ts index 341ecf07d98..3d8ec866d01 100644 --- a/packages/web3-utils/src/hash.ts +++ b/packages/web3-utils/src/hash.ts @@ -330,8 +330,7 @@ export const processSolidityEncodePackedArgs = (arg: Sha3Input): string => { * Encode packed arguments to a hexstring */ export const encodePacked = (...values: Sha3Input[]): string => { - const args = Array.prototype.slice.call(values); - const hexArgs = args.map(processSolidityEncodePackedArgs); + const hexArgs = values.map(processSolidityEncodePackedArgs); return `0x${hexArgs.join('').toLowerCase()}`; };