From 459c50f79339873483e9b6cf5e1ddf02465bd6d7 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Tue, 4 Feb 2025 16:30:39 +0100 Subject: [PATCH] refactor copy --- core/tracing/hooks.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/core/tracing/hooks.go b/core/tracing/hooks.go index b70bd4cd50..26d4578577 100644 --- a/core/tracing/hooks.go +++ b/core/tracing/hooks.go @@ -18,7 +18,6 @@ package tracing import ( "math/big" - "reflect" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -211,17 +210,8 @@ type Hooks struct { // Note: it is not a deep copy. If a hook has been implemented as a closure and acts on // a mutable state, the copied hook will still act on the same state. func (h *Hooks) copy() *Hooks { - copied := &Hooks{} - srcValue := reflect.ValueOf(h).Elem() - dstValue := reflect.ValueOf(copied).Elem() - - for i := 0; i < srcValue.NumField(); i++ { - field := srcValue.Field(i) - if !field.IsNil() { - dstValue.Field(i).Set(field) - } - } - return copied + c := *h + return &c } // BalanceChangeReason is used to indicate the reason for a balance change, useful