-
|
CONTEXT: I am writing an implementation of this library translated into Zig (as part of my own library ecosystem, full credit given in source for the original here). Zig does not have inheritance or virtual class members, so I elected to make each of the 3 However, while translating the original C++ code, I ran into the strange case of After translating thousands of lines of code from a language I am not very familiar with into more than 3k lines of Zig, it is hard to keep track of all the steps in the full process, so I thought I'd just go to the source themself. My main, concrete question is: Is it ever possible (assuming proper operation) for an If not, I can safely remove this level of indirection from my Zig code and reduce the number of allocations performed. Conversely, if this is the case, this may be an avenue to improve the C++ codebase as well if reducing the need to allocate |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Yes, EdgeHolder needs to hold a pointer only because there are 3 possible segment classes. An EdgeHolder cannot hold a pointer to the same edge as another EdgeHolder. It is essentially a |
Beta Was this translation helpful? Give feedback.
Yes, EdgeHolder needs to hold a pointer only because there are 3 possible segment classes. An EdgeHolder cannot hold a pointer to the same edge as another EdgeHolder. It is essentially a
unique_ptrwhich also allows copying by performing a deep copy. Yes, it could be replaced by a union of the three types. (At one point I benchmarked this optimization and the performance difference was too small to justify breaking API compatibility since EdgeHolder is publicly exposed to users of MSDFgen as a library.)