Are pointers faster in structs ? [message #16900] |
Wed, 25 August 1999 00:00 |
Richard Tyc
Messages: 69 Registered: June 1999
|
Member |
|
|
I use a large structure for holding all data in the main widget's user
value.
eg
sState = { btndown: 0b, $
cannEndSel: 0b,$
DataDim: DataDim, $
cube: TEMPORARY(cube) }
cube could be large , say bytarr(512,512,20) Now when the user wants to
load a differnet data set, I guess I have the choice of doing
something like:
sState.cube = 0 ; Free memory to cube ?
newcube = Getnewdata()
sState.cube = TEMPORARY(newcube)
Is this any faster/slower or better/worse than using pointers in the
structure ?
What if I need to initialize the elements of the structure before I have
the size of data ?
I need to define sState first without knowing the size of cube. Could I
do something like :
cubePtr = PTR_NEW(/ALLOCATE_HEAP)
sState = { btndown: 0b, $
cannEndSel: 0b,$
DataDim: DataDim, $
cubePtr: cubePtr }
Then later in code, knowing cube :
cube = bytarr(512,512,20)
sState.cubePtr = PTR_NEW(cube, /NO_COPY)
Is this syntax correct ? Would this be moe efficient then storing cube
directly in sState ?
Thanks in Advance
Rich
-
Attachment: richt.vcf
(Size: 0.29KB, Downloaded 55 times)
|
|
|