Trim comments to the non-obvious why
Drop narration, history and restated-code comments across the repo, keep short ones for security boundaries, upstream quirks and ordering constraints, and record the convention in CLAUDE.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -3,15 +3,8 @@ package graph
|
||||
// This file is hand-written and is never regenerated by gqlgen — it is not
|
||||
// named after a schema file, so `gqlgen generate` leaves it alone.
|
||||
|
||||
// ptrs copies a slice of values into a slice of pointers to those values.
|
||||
//
|
||||
// Every list query loads rows with Find(&xs) into a []T and then has to hand
|
||||
// gqlgen a []*T, because the schema returns lists of nullable objects. Taking
|
||||
// &xs[i] is safe: the slice is never appended to after this point, so the
|
||||
// backing array cannot move and the pointers stay valid.
|
||||
//
|
||||
// Loading straight into a []*T would avoid the copy but changes the query
|
||||
// GORM emits, so the copy is kept deliberately.
|
||||
// ptrs turns []T into []*T for gqlgen. Loading into []*T directly would
|
||||
// change the SQL GORM emits.
|
||||
func ptrs[T any](xs []T) []*T {
|
||||
result := make([]*T, len(xs))
|
||||
for i := range xs {
|
||||
|
||||
Reference in New Issue
Block a user