Does Breaking your Line (\), Cost line-reading performance?

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

Does Breaking your Line (), Cost line-reading performance?

var CameraRotation = Vector3(59, 79, 0)

Compared to a Line of Code as:

var CameraRotation = \
    Vector3(59, 79, 0)

I am dealing with situations where I have many Lines that are long enough, to require up to 4 Breaks for easier readability. Therefor I wonder if these would add to the User’s Computer’s Processing Time due to counting as more lines.

Should these Breaks should be removed upon the Release of a Project? Thank you

:bust_in_silhouette: Reply From: crossbito


No, computers only recognize operations; they don’t perceive “lines” of code. When the processor receives your script, it doesn’t interpret it as the text file you see in the editor; it treats it as its own entity(instructions). Your processor will face more difficulty when executing something like this:

var something = 0.4 / 0.112;

Performing calculations with floating-point numbers is more computationally expensive, as is the case with vectors or matrices. However, these optimizations are generally not necessary unless you are consistently working with highly complex operations in your game.

Thank you for this Information, are there any sources that you would Recommend for Studying more about this?


Nickyroo | 2023-06-06 16:01

Search the documentation provided by processor manufacturers, such as:

AMD: In this PDF, you can find optimizations and best practices.


Although these documents are related to other languages and not specifically to GDScript or C#, the fundamental concepts remain the same. It’s worth noting that not all optimizations described in those books may be applicable to Godot since GDScript and C# may not reach the same level of complexity as the languages covered in those documents.

I wouldn’t recommend optimizing the code prematurely. It is recommended to optimize code when find issues or when performance improvements are necessary. However, gaining knowledge about optimizations and best practices does not harm and would be beneficial in the long run.

crossbito | 2023-06-06 16:21

I edited the answer because the links didn’t work.

crossbito | 2023-06-06 18:53

appreciate these sources

Thanks you :slight_smile:

Nickyroo | 2023-06-06 23:31