do not trust gcc-4.0 to do nrv optimization. (taj khattra)

This commit is contained in:
rsc 2005-12-29 22:10:56 +00:00
parent 1ccd3e1e23
commit e418631bf3

View file

@ -503,42 +503,39 @@ allocdrawbuf(void)
return 0; return 0;
} }
static Param static void
getparam(Memimage *img, Rectangle r, int convgrey, int needbuf) getparam(Param *p, Memimage *img, Rectangle r, int convgrey, int needbuf)
{ {
Param p;
int nbuf; int nbuf;
memset(&p, 0, sizeof p); memset(p, 0, sizeof *p);
p.img = img; p->img = img;
p.r = r; p->r = r;
p.dx = Dx(r); p->dx = Dx(r);
p.needbuf = needbuf; p->needbuf = needbuf;
p.convgrey = convgrey; p->convgrey = convgrey;
assert(img->r.min.x <= r.min.x && r.min.x < img->r.max.x); assert(img->r.min.x <= r.min.x && r.min.x < img->r.max.x);
p.bytey0s = byteaddr(img, Pt(img->r.min.x, img->r.min.y)); p->bytey0s = byteaddr(img, Pt(img->r.min.x, img->r.min.y));
p.bytermin = byteaddr(img, Pt(r.min.x, img->r.min.y)); p->bytermin = byteaddr(img, Pt(r.min.x, img->r.min.y));
p.bytey0e = byteaddr(img, Pt(img->r.max.x, img->r.min.y)); p->bytey0e = byteaddr(img, Pt(img->r.max.x, img->r.min.y));
p.bwidth = sizeof(u32int)*img->width; p->bwidth = sizeof(u32int)*img->width;
assert(p.bytey0s <= p.bytermin && p.bytermin <= p.bytey0e); assert(p->bytey0s <= p->bytermin && p->bytermin <= p->bytey0e);
if(p.r.min.x == p.img->r.min.x) if(p->r.min.x == p->img->r.min.x)
assert(p.bytermin == p.bytey0s); assert(p->bytermin == p->bytey0s);
nbuf = 1; nbuf = 1;
if((img->flags&Frepl) && Dy(img->r) <= MAXBCACHE && Dy(img->r) < Dy(r)){ if((img->flags&Frepl) && Dy(img->r) <= MAXBCACHE && Dy(img->r) < Dy(r)){
p.replcache = 1; p->replcache = 1;
nbuf = Dy(img->r); nbuf = Dy(img->r);
} }
p.bufdelta = 4*p.dx; p->bufdelta = 4*p->dx;
p.bufoff = ndrawbuf; p->bufoff = ndrawbuf;
ndrawbuf += p.bufdelta*nbuf; ndrawbuf += p->bufdelta*nbuf;
return p;
} }
static void static void
@ -640,9 +637,9 @@ alphadraw(Memdrawparam *par)
*/ */
needbuf = (src->data == dst->data); needbuf = (src->data == dst->data);
spar = getparam(src, sr, isgrey, needbuf); getparam(&spar, src, sr, isgrey, needbuf);
dpar = getparam(dst, r, isgrey, needbuf); getparam(&dpar, dst, r, isgrey, needbuf);
mpar = getparam(mask, mr, 0, needbuf); getparam(&mpar, mask, mr, 0, needbuf);
dir = (needbuf && byteaddr(dst, r.min) > byteaddr(src, sr.min)) ? -1 : 1; dir = (needbuf && byteaddr(dst, r.min) > byteaddr(src, sr.min)) ? -1 : 1;
spar.dir = mpar.dir = dpar.dir = dir; spar.dir = mpar.dir = dpar.dir = dir;