News for hackers. Stuff that matters.
Re:Special Cases Are a Code Smell by DarkWiiPlayer on Friday January 25, 2019 @05:20AM (#18996885)
Never mind bugs, imagine that array has 5 million elements. Good luck re-allocating and copying that to add an element at the start and another at the end.
Re:Special Cases Are a Code Smell by dpark on Friday January 25, 2019 @02:57PM (#19001872)
I don't like the approach of pointlessly reallocating the array this way, but 5 million elements is not a problem on any machine built in the last 20 years. That's just 20 megs for 4-byte integers. With modern GC, this is cheap. It's not something you'd want to do in a tight loop (the copy time will start to matter), but for something like the example, the cost (in machine terms) is negligible.