Open thedemons opened 1 year ago
There's a few reasons why I did it like that.
Firstly was an assumption on my part that small value-like structs (vectors and the like) are more naturally passed as values. In particular it means that you can write code like this:
ImVec2 GetPoint() { ... };
ImDrawList_PathLineTo(drawList, GetPoint());
...and not have to store the intermediate out to a variable.
Secondly, it seemed like it was more likely to give the compiler opportunities for optimisation (versus potentially forcing an unnecessary store out to memory just to have an address to pass). I can't say I have any concrete evidence either way on that one, but intuitively it seemed reasonable.
Finally, cimgui uses pass-by-value in those situations, so I figured that unless there was a compelling reason not to it would probably make sense to follow suit!
Do you have a specific usage pattern or optimisation scenario which would benefit from passing const pointers instead?
ImDrawList::PathLineTo(const ImVec2& pos)
ImDrawList_PathLineTo(ImDrawList* self, ImVec2 pos)
Why don't we use const pointers (
const ImVec2* pos
) instead? What leads to this decision?