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
|
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 {
|
if card == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -101,18 +101,18 @@ func vcardPropFilter(card *vcard.Card, props []string) *vcard.Card {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result := make(vcard.Card)
|
result := make(vcard.Card)
|
||||||
result["VERSION"] = (*card)["VERSION"]
|
result["VERSION"] = card["VERSION"]
|
||||||
for _, prop := range props {
|
for _, prop := range props {
|
||||||
value, ok := (*card)[prop]
|
value, ok := card[prop]
|
||||||
if ok {
|
if ok {
|
||||||
result[prop] = value
|
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)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -125,7 +125,7 @@ func vcardFromFile(path string, propFilter []string) (*vcard.Card, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return vcardPropFilter(&card, propFilter), nil
|
return vcardPropFilter(card, propFilter), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createDefaultAddressBook(path string) error {
|
func createDefaultAddressBook(path string) error {
|
||||||
@ -207,7 +207,7 @@ func (b *filesystemBackend) GetAddressObject(ctx context.Context, path string, r
|
|||||||
Path: path,
|
Path: path,
|
||||||
ModTime: info.ModTime(),
|
ModTime: info.ModTime(),
|
||||||
ETag: etag,
|
ETag: etag,
|
||||||
Card: *card,
|
Card: card,
|
||||||
}
|
}
|
||||||
return &obj, nil
|
return &obj, nil
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ func (b *filesystemBackend) loadAll(ctx context.Context, propFilter []string) ([
|
|||||||
Path: "/" + filepath.Base(filename),
|
Path: "/" + filepath.Base(filename),
|
||||||
ModTime: info.ModTime(),
|
ModTime: info.ModTime(),
|
||||||
ETag: etag,
|
ETag: etag,
|
||||||
Card: *card,
|
Card: card,
|
||||||
}
|
}
|
||||||
result = append(result, obj)
|
result = append(result, obj)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user