Smarter computation of the required space for the struct.
This commit was SVN r1090.
Этот коммит содержится в:
родитель
1fb66840e1
Коммит
434ebd2dfc
@ -5,40 +5,49 @@
|
||||
int lam_ddt_create_struct( int count, int* pBlockLength, long* pDisp,
|
||||
dt_desc_t** pTypes, dt_desc_t** newType )
|
||||
{
|
||||
int i;
|
||||
long disp, endto, lastExtent, lastDisp;
|
||||
int lastBlock;
|
||||
dt_desc_t *pdt, *lastType;
|
||||
/* if we compute the total number of elements before we can
|
||||
* avoid increasing the size of the desc array often.
|
||||
*/
|
||||
for( disp = 0, i = 0; i < count; i++ ) {
|
||||
disp += pTypes[i]->desc.used;
|
||||
if( pBlockLength[i] != 1 ) disp += 2;
|
||||
}
|
||||
lastType = pTypes[0];
|
||||
lastBlock = pBlockLength[0];
|
||||
lastExtent = lastType->ub - lastType->lb;
|
||||
lastDisp = pDisp[0];
|
||||
endto = pDisp[0] + lastExtent * lastBlock;
|
||||
int i;
|
||||
long disp, endto, lastExtent, lastDisp;
|
||||
int lastBlock;
|
||||
dt_desc_t *pdt, *lastType;
|
||||
/* if we compute the total number of elements before we can
|
||||
* avoid increasing the size of the desc array often.
|
||||
*/
|
||||
for( lastType = pTypes[0], lastBlock = 0, disp = 0, i = 0; i < count; i++ ) {
|
||||
if( lastType == pTypes[i] ) {
|
||||
lastBlock += pBlockLength[i];
|
||||
} else {
|
||||
disp += lastType->desc.used;
|
||||
if( lastBlock != 1 ) disp += 2;
|
||||
lastType = pTypes[i];
|
||||
lastBlock = pBlockLength[i];
|
||||
}
|
||||
}
|
||||
disp += lastType->desc.used;
|
||||
if( lastBlock != 1 ) disp += 2;
|
||||
|
||||
pdt = lam_ddt_create( disp );
|
||||
lastType = pTypes[0];
|
||||
lastBlock = pBlockLength[0];
|
||||
lastExtent = lastType->ub - lastType->lb;
|
||||
lastDisp = pDisp[0];
|
||||
endto = pDisp[0] + lastExtent * lastBlock;
|
||||
|
||||
for( i = 1; i < count; i++ ) {
|
||||
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
|
||||
lastBlock += pBlockLength[i];
|
||||
endto = lastDisp + lastBlock * lastExtent;
|
||||
} else {
|
||||
lam_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
|
||||
lastType = pTypes[i];
|
||||
lastExtent = lastType->ub - lastType->lb;
|
||||
lastBlock = pBlockLength[i];
|
||||
lastDisp = pDisp[i];
|
||||
endto = lastDisp + lastExtent * lastBlock;
|
||||
}
|
||||
}
|
||||
lam_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
|
||||
pdt = lam_ddt_create( disp );
|
||||
|
||||
*newType = pdt;
|
||||
return 0;
|
||||
for( i = 1; i < count; i++ ) {
|
||||
if( (pTypes[i] == lastType) && (pDisp[i] == endto) ) {
|
||||
lastBlock += pBlockLength[i];
|
||||
endto = lastDisp + lastBlock * lastExtent;
|
||||
} else {
|
||||
lam_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
|
||||
lastType = pTypes[i];
|
||||
lastExtent = lastType->ub - lastType->lb;
|
||||
lastBlock = pBlockLength[i];
|
||||
lastDisp = pDisp[i];
|
||||
endto = lastDisp + lastExtent * lastBlock;
|
||||
}
|
||||
}
|
||||
lam_ddt_add( pdt, lastType, lastBlock, lastDisp, lastExtent );
|
||||
|
||||
*newType = pdt;
|
||||
return 0;
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user