forked from hailey.at/cocoon
An atproto PDS written in Go

nitpicks from yesterday's changes (#9)

* µopt: only do one allocation here

* just check if preferences is a key of the prefs obj

i think json.Unmarshal can give u a non-nil guy here and checking for
nil or empty is kinda cringe so let's just do this

authored by charlotte ✨ and committed by GitHub ee7ced39 e29f103c

+1 -1
server/handle_actor_get_preferences.go
··· 14 14 15 15 var prefs map[string]any 16 16 err := json.Unmarshal(repo.Preferences, &prefs) 17 - if err != nil || prefs == nil { 17 + if err != nil || prefs["preferences"] == nil { 18 18 prefs = map[string]any{ 19 19 "preferences": map[string]any{}, 20 20 }
+1 -1
server/handle_repo_describe_repo.go
··· 69 69 return helpers.ServerError(e, nil) 70 70 } 71 71 72 - var collections []string = make([]string, 0) 72 + var collections []string = make([]string, 0, len(records)) 73 73 for _, r := range records { 74 74 collections = append(collections, r.Nsid) 75 75 }