krychu / wfc

Wave Function Collapse library in C, plus a command-line tool
343 stars 20 forks source link

Const Function Parameters #11

Closed nsmryan closed 2 years ago

nsmryan commented 2 years ago

I added 'const' qualifiers for function arguments that are not modified. I did a pass through the code, but it is possible that I missed some arguments. However, I did find 17 parameters that can be 'const'.

There appears to be no effect on performance.

If you don't prefer to mark const parameters, feel free to reject the PR. This is my personal preference when writing C.

krychu commented 2 years ago

I used to const as much as possible in the past. But opted for less verbosity over time.

const in this case won't prevent us from modifying wfc->image, wfc->tiles, wfc->cells, wfc->props, wfc->allowed_tiles. Is this something you feel strongly about?

nsmryan commented 2 years ago

Good point about wfc fields. I don't feel particularly strongly about it, its just something I came across while packaging up the code. I will just close the PR, with the resolution that const doesn't add much here and clutters a bit with verbosity.