+1 vote

This is a "performance" related question.

Le'ts say I have around 50 instances running around, checking 3 different conditions every frame, will the second code be faster than the first one?

func _process(delta):
    if Something_Common and Something_That_Is_Rare and Something_SUPER_rare:

func _process(delta):
     if Something_SUPER_rare and Something_That_Is_Rare and Something_Common:

In other other words, should I ask the engine to check the rarest condition first so he can move on, instead of going all the way every single frame?

asked Apr 20, 2018 in Engine by DwarvenTrader (16 points)

1 Answer

+2 votes
Best answer

I'm not 100% sure about Godot but every programming language I know of does this.

So yeah, putting them in order from rarest to most common makes sense (or not if checking rarest one would take much longer than the rest).

answered Apr 20, 2018 by HalfTough (109 points)
selected Apr 24, 2018 by DwarvenTrader
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.