From 31e63fcf66188504e0b1941059394cf5df49bc17 Mon Sep 17 00:00:00 2001 From: cui <523516579@qq.com> Date: Tue, 2 Apr 2024 16:47:15 +0800 Subject: [PATCH] rlp: using maps.Clone (#29434) --- rlp/typecache.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rlp/typecache.go b/rlp/typecache.go index 3e37c9d2fc..eebf4cd611 100644 --- a/rlp/typecache.go +++ b/rlp/typecache.go @@ -18,6 +18,7 @@ package rlp import ( "fmt" + "maps" "reflect" "sync" "sync/atomic" @@ -90,10 +91,7 @@ func (c *typeCache) generate(typ reflect.Type, tags rlpstruct.Tags) *typeinfo { } // Copy cur to next. - c.next = make(map[typekey]*typeinfo, len(cur)+1) - for k, v := range cur { - c.next[k] = v - } + c.next = maps.Clone(cur) // Generate. info := c.infoWhileGenerating(typ, tags)