|
|
|
|
|
by porridgeraisin
457 days ago
|
|
We are talking about making an array with unique elements here. You cannot know the correct capacity for that without overallocating. If overallocating is indeed OK for your usecase, then you can do so yourself uniq := make([]MyObject, 0, len(my_objects))
|
|
Yes, you can always just write more and more and more code to fix these things. Or you could just… not write more code and still get optimal performance.