]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Change some metainfo.MetaInfo methods to take pointer receivers
authorMatt Joiner <anacrolix@gmail.com>
Tue, 23 Jul 2024 08:58:59 +0000 (18:58 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 23 Jul 2024 08:58:59 +0000 (18:58 +1000)
It's kind of unnecessary to take them by value here, and, slower. Use Rust instead!!

metainfo/metainfo.go

index 56d4ce59ce3039b07122702990dc5b0639629af3..71c68e458405354820eaf398af368ae03a7cf950 100644 (file)
@@ -58,7 +58,7 @@ func LoadFromFile(filename string) (*MetaInfo, error) {
        return Load(&buf)
 }
 
-func (mi MetaInfo) UnmarshalInfo() (info Info, err error) {
+func (mi *MetaInfo) UnmarshalInfo() (info Info, err error) {
        err = bencode.Unmarshal(mi.InfoBytes, &info)
        return
 }
@@ -68,7 +68,7 @@ func (mi *MetaInfo) HashInfoBytes() (infoHash Hash) {
 }
 
 // Encode to bencoded form.
-func (mi MetaInfo) Write(w io.Writer) error {
+func (mi *MetaInfo) Write(w io.Writer) error {
        return bencode.NewEncoder(w).Encode(mi)
 }