+1 vote

I am quering a variable stored in an autoload singleton, with if elif I must call global.var every time I use the variable. but if I use the match I only call the variable once ... will that make the query slightly faster?

in Engine by (78 points)

Is retrieving global variables that slow?

apparently there is no effect on speed

1 Answer

+3 votes
Best answer

match and if get compiled as the same sets of instructions, none is particularly faster than the other. match is essentially a different way to express things in a more concise way. It certainly makes you write the variable only once, but it still has to compare its value for each case (i.e it's not a jump table like in C).

by (27,964 points)
selected by

oh ok, thanks ! very useful

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.