10-11-2025 01:38 AM
Hi, can someone explain to me which of the two images contains the more efficient code ?
Solved! Go to Solution.
10-11-2025 07:11 AM
My gut feel is that these are basically equivalent. It is possible the compiler creates the same code. Even then, the difference between these two will be so minute it probably is not worth the effort.
10-11-2025 03:32 PM
Hi Charlie,
Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".
Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?
Regards,
Raphaël.
10-13-2025 03:43 AM
@raphschru wrote:
Hi Charlie,
Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".
Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?
It has indeed a possible code smell. Looks like a linked list implementation. It might be eligible, but it feels itchy.
10-13-2025 11:45 AM
@raphschru wrote:
Hi Charlie,
Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".
Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?
Regards,
Raphaël.
I think this is just an "alternate" version of the way GOOP does its "by-reference" implementation. GOOP flattens a DVR pointer to a U32 and stores that since it can't have a DVR of itself inside itself. A class containing a DVR to a "LabVIEW object" is also non-recursive but can still store an instance of itself inside of itself during runtime. The fact that it's unbundling a "Variant" is likely just part of the code example.
10-13-2025 04:06 PM
@Kyle97330 a écrit :
@raphschru wrote:
Hi Charlie,
Regarding performances, I would be more concerned about the fact that your object contains another object of the same class inside the DVR, on which you have to use "to more specific".
Why not having a DVR to a variant directly (or maybe a DVR to a cluster containing the variant)?
Regards,
Raphaël.
I think this is just an "alternate" version of the way GOOP does its "by-reference" implementation. GOOP flattens a DVR pointer to a U32 and stores that since it can't have a DVR of itself inside itself. A class containing a DVR to a "LabVIEW object" is also non-recursive but can still store an instance of itself inside of itself during runtime. The fact that it's unbundling a "Variant" is likely just part of the code example.
Now that I think about it, the class may have some methods that operate on the "by-ref" version of the class (where "variant" data is void), and other methods that operate on the "by-value" version of the class (where "DVR" is null). I don't think this is for class composition though.
10-13-2025 11:57 PM - edited 10-14-2025 12:03 AM
Kyle97330 understood the code very well. Do not bother with the variant unbundle. I am using this construction very often to get the attributes from the class instance stored in the DVR. It is called many times, so I was wondering if the code is optimized as much as possible.