From 43e5250c617626c108333384d67c0e05f87f19e7 Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 23 May 2024 04:51:06 +0800 Subject: [PATCH 1/4] metainfo/announcelist.go : add clear() func --- metainfo/announcelist.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metainfo/announcelist.go b/metainfo/announcelist.go index f19af14ccd..abc68bbfc5 100644 --- a/metainfo/announcelist.go +++ b/metainfo/announcelist.go @@ -33,3 +33,7 @@ func (al AnnounceList) DistinctValues() (ret []string) { } return } + +func (al AnnounceList) Clear() { + clear(al) +} From d94e00793e9f8c6dff3759497e500202b15a6917 Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 23 May 2024 04:52:02 +0800 Subject: [PATCH 2/4] fmt --- webseed/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webseed/client.go b/webseed/client.go index 5e3c28b885..7740fb8ed9 100644 --- a/webseed/client.go +++ b/webseed/client.go @@ -188,4 +188,4 @@ func readRequestPartResponses(ctx context.Context, parts []requestPart) (_ []byt } } return buf.Bytes(), err -} \ No newline at end of file +} From 614527868dfdd0b03eb30ba195f64cdb24c1217d Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 23 May 2024 05:06:07 +0800 Subject: [PATCH 3/4] use clone since 1.22 in go.mod --- metainfo/announcelist.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/metainfo/announcelist.go b/metainfo/announcelist.go index abc68bbfc5..fccfbbf25e 100644 --- a/metainfo/announcelist.go +++ b/metainfo/announcelist.go @@ -1,12 +1,11 @@ package metainfo +import "slices" + type AnnounceList [][]string -func (al AnnounceList) Clone() (ret AnnounceList) { - for _, tier := range al { - ret = append(ret, append([]string(nil), tier...)) - } - return +func (al AnnounceList) Clone() AnnounceList { + return slices.Clone(al) } // Whether the AnnounceList should be preferred over a single URL announce. From 5f2dad16d5181acf5e18589b08ae8d3e51d2d897 Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 23 May 2024 06:47:33 +0800 Subject: [PATCH 4/4] clear and free --- metainfo/announcelist.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metainfo/announcelist.go b/metainfo/announcelist.go index fccfbbf25e..c6ed907d1f 100644 --- a/metainfo/announcelist.go +++ b/metainfo/announcelist.go @@ -34,5 +34,5 @@ func (al AnnounceList) DistinctValues() (ret []string) { } func (al AnnounceList) Clear() { - clear(al) + al = nil }