Reducing gas costs while minting

Is it safe to define the token id outside of a minting loop and increment per loop as below:

uint256 supply = totalSupply();
for (uint i = 1; i <=  numFati; i++) {
    _safeMint(msg.sender, (supply + i));
}

or should I call totalSupply() for every single mint like so:

for (uint i = 1; i <=  numFati; i++) {
    _safeMint(msg.sender, totalSupply());
}

I’m interested in reducing the gas costs as much as possible but I worry about multiple mintings occurring simultaneously

I think the first one will use less gas, I am not sure, but you can have a test by this tool:

Will the first method be safe if 2 users try to buy x20 each? Or is there the chance of token_id conflicts?

I think all transactions are executed one by one, that is only one user can be performing an operation at a given time, so I think there is no chance of token_id conflicts.

Thanks for letting me know, super helpful