> I need to allocate an array but I don't want to pay for initializing
> it to 0 all over; the data structure I have is designed to work safely
> with un-initialized memory, so it's just wasted cycles for me. I've
> looked around a bit and found unsafe.NewArray() but that seems to do
> zero-initialization too. Is runtime.Alloc() what I want? Yes, I know,
> it's not "proper" to worry about this and I should just use the
> portable and documented initialized arrays. I still want to have
> un-initialized ones. :-D
Sorry, not possible. And premature optimization.
I assume you're using a Briggs/Torczon style sparse set
or some other similar lazy data structure. The cost of zeroing
those at allocation time is not the big savings. The big savings
is not needing to re-zero them in the reset() operation.
An even bigger savings is using them across multiple operations
instead of throwing off tons of garbage. The zeroing at
allocation just doesn't enter the picture, and the cost for zeroing
large data structures is typically paid by background goroutines
anyway.
Russ