Get a variable from Auto-load Costs more performance?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nickyroo

I have an Autoloaded Settings Script, Containing “Mouse_Sensitivity”

Would it cause any difference in performance if I were to write:

(MyTurning) * get_node("SettingsPath").Mouse_Sensitivity

Instead of rather Saving the Script as an Onready Variable as “Settings”, and Saying:

@onready var Settings = get_node("SettingsPath")

func _input():
    (MyTurning) * Settings.Mouse_Sensitivity

Thank you to whoever would answer

:bust_in_silhouette: Reply From: bigstinky

I think the first method would add an extra function call every time you want to execute that code, but the difference in performance would probably be imperceptible. It would probably be better to go for the second option more so because it is more readable, than the difference in performance. now that I think about it, if your script is an autoloaded singleton the node should be available in any script. This means that you should be able to do “Settings.Mouse_Sensitivity” without having to get a reference to the Settings instance beforehand