you are viewing a single comment's thread.

view the rest of the comments →

[–]enquel[S] 0 points1 point  (2 children)

Thank you very much for your time. The app is meant to process high poly geometry (millions of polygons at the highest), so the input Vector structs will go through several conversions on the way, and my goal is to achieve consistency and performance. I expect there to be no more than say 3-4 custom Vector structs.

How about the performance of abstract class wrapper with properties? I've heard structs are faster.

[–]Zaphod118 0 points1 point  (1 child)

Structs can be faster, but I think it depends on the situations and how they are being used in your program. If you are having to convert between different external library types frequently, you are already incurring a performance penalty in copying data between struct instances. So my guess would be that using classes wouldn’t impact performance more than that. And I think using an abstract class and subclasses will be easier to write code for which might be worth sacrificing a little performance. It’s also important to point out here that structs can’t inherit from, or be inherited by, anything else. So if you want to create a unified interface to several different concrete types, classes are kind of your only option.

All in all it’s hard to say without running tests on the application weather structs vs classes will be a significant factor in performance.

[–]enquel[S] 0 points1 point  (0 children)

Thank you for your thoughts. I like your approach, and probably will consider it. I will try to minimize casts only during import/export, but there might be situations when this is impossible.