2 ms·
I think the stuff about nested loops performing poorly is a misunderstanding. There's nothing inherently bad about nested loops. The motivation given in the pre
by nemetroid 8y ago
I think the stuff about nested loops performing poorly is a misunderstanding. There's nothing inherently bad about nested loops. The motivation given in the previous post[0] is:
> The big breakthrough I had was after looking at the hot function I realised that storing the game events in a List of Arrays meant that we had a loop in a loop. It was however possible to flatten this into a single array of integers and reset the game every 11 turns with a simple if check.
The issue here wasn't nested loops, it was data structure overhead and poor data locality from having a lot of tiny lists (11 items each, as I understand it).
0: https://boyter.org/2017/03/golang-solution-faster-equivalent-java-solution/ https://boyter.org/2017/03/golang-solution-faster-equivalent...
- saagarjha 8y agoThe author recognizes this for certain cases: > Turns out that at this small level of nested looping there is no performance to be gained here.