06-07-2019 01:36 PM
@mcduff wrote:The compiler decides when to make a copy. Look at Bob's code, there is no copy; not sure why.
I may be wrong about this, but I think the point of the Swap was ... to swap memory pointers (quick) and avoid copying memory (potentially slow, particularly for large arrays).
A (final?) remark -- this "trick" was buried deep inside a Waveform Signal Generator VI, where it possibly can (without anyone noticing) save a few cycles from time to time. Should you memorize this "trick" and use it in your routine coding practices? Probably not -- your time is probably more valuable than the microseconds you'll save by using this (and causing further confusion when someone discovers what you did, and posts to the Forum and there follows a week's worth of discussion and more testing and ...). Sometime the Clean, Straight-forward Way is better ...
Bob Schor
06-07-2019 02:46 PM
@Bob_Schor
look they where the buffer allocation occurs, it is before the swap function.
mcduff
06-07-2019 04:01 PM
I feel that we are "beating a dead horse". At some point, the LabVIEW Developers "buried" a clever technique that (under some circumstances) may save a few CPU cycles at the expense, perhaps, of "coding clarity" (as in "Why did they do it that way") (answer -- to save a few CPU cycles at the expense of Coding Clarity, hoping people wouldn't make a big fuss about it). I'm happy to continue a conversation via Private Message, but I'm going to "drop out" of this public discussion for now.
Bob Schor