r/GraphicsProgramming • • Aug 14 '22

Finally!!!!! Red Triangle%

Post image
330 Upvotes

27 comments sorted by

View all comments

8

u/314kabinet Aug 14 '22

Congrats! But for god’s sake, use const.

0

u/[deleted] Aug 14 '22

[deleted]

5

u/314kabinet Aug 14 '22

In the absolute majority of cases, no. Const-correctness just makes it easier for humans reason about code (e.g. “ok, this part can’t be the one changing the value”).

However, there can be situations where the compiler can’t figure out if a value will be changed in a particular code path, and ao can’t apply optimizations that rely on the value staying the same.