diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index dbbfabac6..e82937ead 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -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;