Code RoomSlice append without capacity
HardPrep Room Coding #1927

Slice append without capacity

Code reviewCode quality & reviewSenior–Staff~20 min

Review this Go function that builds a slice of ids from a large result set. It shows up high in allocation profiles.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1func collectIDs(rows []Row) []int64 {
2 var ids []int64
3 for _, r := range rows {
4 ids = append(ids, r.ID)
5 }
6 return ids
7}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.