refactor: use maps.Copy for cleaner map handling

Signed-off-by: xinhangzhou <shuangcui@aliyun.com>
This commit is contained in:
xinhangzhou
2025-03-24 17:13:47 +08:00
parent 5235f3b24f
commit b7e3c20383
7 changed files with 18 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"maps"
"sort"
"github.com/lightningnetwork/lnd/fn/v2"
@@ -94,13 +95,8 @@ func (c CustomRecords) Copy() CustomRecords {
// records will be used.
func (c CustomRecords) MergedCopy(other CustomRecords) CustomRecords {
copiedRecords := make(CustomRecords, len(c))
for k, v := range c {
copiedRecords[k] = v
}
for k, v := range other {
copiedRecords[k] = v
}
maps.Copy(copiedRecords, c)
maps.Copy(copiedRecords, other)
return copiedRecords
}