Syomus / ProceduralToolkit

Procedural generation library for Unity
https://assetstore.unity.com/packages/tools/utilities/procedural-toolkit-16508
MIT License
2.64k stars 229 forks source link

Remove ref usage in MeshDraft.ToMesh #62

Closed olee closed 3 years ago

olee commented 5 years ago

MeshDraft.ToMesh(ref Mesh mesh) could be fully replaced with MeshDraft.ToMesh(Mesh mesh). There is no use to use any ref here and it just makes code more ineffective and unintuitive.

BasmanovDaniil commented 5 years ago

Hello! The point of this ref is to explicitly show that the parameter will be modified inside the method. While it indeed can be omitted, without it you will have to look at the source code to understand what is happening. And the performance overhead (if it even exists) is insignificant. It is not a very common pattern, but it is useful to experss the intent behind the method.

olee commented 5 years ago

Though then I'd say to rather make the intent clear through naming the function properly like AssignToMesh(Mesh mesh) or something like that? However using a ref here prevents using this function in some places which is why I had to rewrite it locally which I don't think is enough to leave out the stylistic ref usage there.

BasmanovDaniil commented 5 years ago

What was your use case? Can you provide an example?