From 86359a5e11e657f39e46d2bbc8041f85c9729106 Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Wed, 16 Mar 2022 14:51:26 +0100 Subject: [PATCH] Avoid using pointers for card.Card It's just a map, Go will do the right thing. --- storage/filesystem.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/filesystem.go b/storage/filesystem.go index 24f8465..6de19e4 100644 --- a/storage/filesystem.go +++ b/storage/filesystem.go @@ -91,7 +91,7 @@ func etagForFile(path string) (string, error) { return base64.StdEncoding.EncodeToString(csum[:]), nil } -func vcardPropFilter(card *vcard.Card, props []string) *vcard.Card { +func vcardPropFilter(card vcard.Card, props []string) vcard.Card { if card == nil { return nil } @@ -101,18 +101,18 @@ func vcardPropFilter(card *vcard.Card, props []string) *vcard.Card { } result := make(vcard.Card) - result["VERSION"] = (*card)["VERSION"] + result["VERSION"] = card["VERSION"] for _, prop := range props { - value, ok := (*card)[prop] + value, ok := card[prop] if ok { result[prop] = value } } - return &result + return result } -func vcardFromFile(path string, propFilter []string) (*vcard.Card, error) { +func vcardFromFile(path string, propFilter []string) (vcard.Card, error) { f, err := os.Open(path) if err != nil { return nil, err @@ -125,7 +125,7 @@ func vcardFromFile(path string, propFilter []string) (*vcard.Card, error) { return nil, err } - return vcardPropFilter(&card, propFilter), nil + return vcardPropFilter(card, propFilter), nil } func createDefaultAddressBook(path string) error { @@ -207,7 +207,7 @@ func (b *filesystemBackend) GetAddressObject(ctx context.Context, path string, r Path: path, ModTime: info.ModTime(), ETag: etag, - Card: *card, + Card: card, } return &obj, nil } @@ -240,7 +240,7 @@ func (b *filesystemBackend) loadAll(ctx context.Context, propFilter []string) ([ Path: "/" + filepath.Base(filename), ModTime: info.ModTime(), ETag: etag, - Card: *card, + Card: card, } result = append(result, obj) return nil