mhx: minimize realloc, rlar: this is evil for large circuits with few timesteps

This commit is contained in:
dwarning 2015-04-01 22:21:27 +02:00 committed by rlar
parent 597cc33b18
commit ec958fc861
1 changed files with 6 additions and 3 deletions

View File

@ -946,6 +946,7 @@ fileStartPoint(FILE *fp, bool bin, int num)
}
/* This code is used when one does RUN aap.raw but *not* when doing RUN. */
static void
fileAddRealValue(FILE *fp, bool bin, double value)
{
@ -1059,6 +1060,8 @@ plotInit(runDesc *run)
}
}
/* mhx: minimize the number of REALLOCs */
#define OUTSIZE (256*4096)
static void
plotAddRealValue(dataDesc *desc, double value)
@ -1066,11 +1069,11 @@ plotAddRealValue(dataDesc *desc, double value)
struct dvec *v = desc->vec;
if (isreal(v)) {
v->v_realdata = TREALLOC(double, v->v_realdata, v->v_length + 1);
if ((v->v_dims[0] & (OUTSIZE - 1)) == 0) v->v_realdata = TREALLOC(double, v->v_realdata, v->v_length + OUTSIZE);
v->v_realdata[v->v_length] = value;
} else {
/* a real parading as a VF_COMPLEX */
v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + 1);
if ((v->v_dims[0] & (OUTSIZE - 1)) == 0) v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + OUTSIZE);
v->v_compdata[v->v_length].cx_real = value;
v->v_compdata[v->v_length].cx_imag = 0.0;
}
@ -1085,7 +1088,7 @@ plotAddComplexValue(dataDesc *desc, IFcomplex value)
{
struct dvec *v = desc->vec;
v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + 1);
if ((v->v_dims[0] & (OUTSIZE - 1)) == 0) v->v_compdata = TREALLOC(ngcomplex_t, v->v_compdata, v->v_length + OUTSIZE);
v->v_compdata[v->v_length].cx_real = value.real;
v->v_compdata[v->v_length].cx_imag = value.imag;