11-10-2009 11:32 AM
"Don't use shift registers with large array if at all possible. LV makes a copy of the contents of a shift register for each loop iteration."
This comment was in some code I came accross today, and there was a read local at the beginning of the loop (inside) and write local (inside) at the end. Is this a truthful statement? Don't locals make a copy (also?)
11-10-2009 11:42 AM
for(imstuck) wrote:"Don't use shift registers with large array if at all possible. LV makes a copy of the contents of a shift register for each loop iteration."
This comment was in some code I came accross today, and there was a read local at the beginning of the loop (inside) and write local (inside) at the end. Is this a truthful statement? Don't locals make a copy (also?)
Re: SRs
FALSE!
Re:Locals
TRUE
So you are correct and that comment is bogus.
Ben
11-10-2009 11:50 AM
11-10-2009 12:06 PM
Awesome, I'll look into that. We have later versions floating around, I just don't have one on my machine.
I was going to say, I thought shift registers just accessed some spot in memory, and didn't copy anything.
11-10-2009 12:12 PM
for(imstuck) wrote:Awesome, I'll look into that. We have later versions floating around, I just don't have one on my machine.
I was going to say, I thought shift registers just accessed some spot in memory, and didn't copy anything.
That is correct!
Of course you could force LV to do otherwise by building an array in a loop, but even then it works in a single buffer (spot in memory) provided the "spot" is big enough. Get familiar with the Show buffers that Jeff mentioned to "get the feel" for yourself.
Ben
11-14-2009 02:15 PM
for(imstuck) wrote:"Don't use shift registers with large array if at all possible. LV makes a copy of the contents of a shift register for each loop iteration."
This reminds me of labuda's quote here from many years ago:
@labuda wrote:The problem comes out when you have 500 000 items to remove from the list. If you simply use the loop + shift register, then you end up clogging your computer; because your 1 000 000 size array goes back and forth.
Despite the beatiful choice of words (clogging your computer, goes back and forth, etc.), we are dealing with a serious misconception and misinformation (read my reply in the above link).
...Actually, that entire thread is worth a read. 🙂