11 ms·
I had a 1 minute look at the "optimized" C code - it's calling malloc for every word.
by yb303 4y ago
I had a 1 minute look at the "optimized" C code - it's calling malloc for every word.
- Areading314 4y agoDoesn't malloc return a pointer? Sounds unsafe
- yb303 4y agoThat's not the point. It's perfectly safe and there's nothing else in C. The point is you don't have to call this function for every single word. It takes time and pointer increment doesn't
- centilliard 4y agoOoo... spooooky pointers... ancient prophecies speak of the Earth splitting in half and swallowing everyone who's ever thought about allocating memory.
- Arnavion 4y ago>I had a 1 minute look at the "optimized" C code - it's calling malloc for every word. Neither simple.c nor optimized.c call malloc "for every word". They only call malloc when inserting a previously-unseen word into the counting map.