Avoid using pointers for card.Card
It's just a map, Go will do the right thing.
This commit is contained in:
parent
e069bc0e9b
commit
86359a5e11
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user