Does having a single "run-time-for-loop" decrease performance?

Heya!
I’ve been wondering if running a for loop only ONCE is worse performance wise than just running a single line of code.

This might sound like a useless question but I have a use case lol (more at the end of the post).

What I mean with running a for loop once:

for i = 1, 1, do
-- Code stuff
end

What I mean with running a line of code:

-- Code stuff (no loop which runs this)

My use case would be this:
I want my code in the loop to run the value of x. But x is not always given and it depends on the situation. With the below I wanted to prevent to repeat my code twice.

for i = 1, x or 1 do
-- code stuff
end

Hopefully someone can tell me.
Thanks.

Possible performance decrease is almost invisible, if you don’t run this code like few milion times per second there shouldn’t be any memory drop, also why do you want to use this solution? you can create function and call it

if not x then Callback() return end
for i = 1, x do
    Callback()
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.