47 ms·
Nice one Mike! My one improvement would be using realloc in the out-of-space case vs. malloc+memcpy+free. http://www.cplusplus.com/reference/cstdlib/realloc/ h
by awolf 14y ago
Nice one Mike! My one improvement would be using realloc in the out-of-space case vs. malloc+memcpy+free.
http://www.cplusplus.com/reference/cstdlib/realloc/ http://www.cplusplus.com/reference/cstdlib/realloc/
- masklinn 14y agoAlthough I had the same initial reaction, in the comments he explains he willfully used malloc/memcpy/free to demonstrate the underlying behavior.
- mikeash 14y agoRight. The reallocation behavior is so fundamental to the implementation of NSMutableArray that there seemed no point in calling realloc directly. If I did that, might as well just use NSMutableArray instead of writing my own, and then there wouldn't be anything to write about.