lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Nov 23, 2020 at 7:12 PM Roberto Ierusalimschy wrote:
>    for j = base_index + game_size, base_index + 2*game_size - 1 do
>       game_field[j] = nil
>    end

Anyone that spends time initializing an array with nil's is not
really concerned with performance. If you remove that pointless
loop from the program, the difference disapears.


This loop is not pointless.
It clears the cells which may contain "black" or "white" pieces from the previous game.
The function initialize_game_field() is invoked on every game start.


 
(This issue is really a simple variation of what was discussed in this
list a short time ago.)

Yes, it's the same bug.
Your previous opinion was:
"It does not occur often in real code, so we can treat it as a rare worst-case situation and don't fix"
But your explanation is not pertinent to this new bugreport.
We fill the array consequently from min index to max index.
It's the most common situation. 
Everyone is doing exactly this way when initializing an array.
Can you say now: "It does not occur often in real code"?